=================================================================== RCS file: /cvs/prex-old/usr/server/proc/proc.h,v retrieving revision 1.1.1.1 retrieving revision 1.1.1.1.2.1 diff -u -r1.1.1.1 -r1.1.1.1.2.1 --- prex-old/usr/server/proc/proc.h 2008/06/03 10:38:51 1.1.1.1 +++ prex-old/usr/server/proc/proc.h 2008/08/13 17:12:45 1.1.1.1.2.1 @@ -33,21 +33,19 @@ #include #include #include -#include #include #include +#include #include #include -#ifdef DEBUG /* #define DEBUG_PROC 1 */ -#endif #ifdef DEBUG_PROC -#define dprintf(fmt, args...) syslog(LOG_DEBUG, "proc: " fmt, ## args) +#define DPRINTF(a) dprintf a #else -#define dprintf(fmt...) do {} while (0) +#define DPRINTF(a) #endif #define PRIO_PROC 130 /* priority of process server */ @@ -56,35 +54,48 @@ #define ID_MAXBUCKETS 32 #define IDHASH(x) ((x) & (ID_MAXBUCKETS - 1)) +struct proc; + /* + * Session + */ +struct session { + int s_refcnt; /* reference count */ + struct proc *s_leader; /* session leader */ + int s_ttyhold; /* true if hold tty */ +}; + + +/* * Process group */ struct pgrp { - struct list pgid_link; /* link for pgid hash */ - struct list members; /* list head of processes */ - pid_t pgid; /* pgrp id */ + struct list pg_link; /* link for pgid hash */ + struct list pg_members; /* list head of processes */ + struct session *pg_session; /* pointer to session */ + pid_t pg_pgid; /* pgrp id */ }; /* - * Description of a process. + * Description of a process */ struct proc { - struct list link; /* link for all processes */ - struct proc *parent; /* pointer to parent process */ - struct list children; /* list head of child processes */ - struct list sibling; /* link for sibling processes */ - struct list pid_link; /* link for pid hash */ - struct list task_link; /* link for task hash */ - struct list pgrp_link; /* link for process group */ - struct pgrp *pgrp; /* pointer to process group */ - int stat; /* process status S* */ - int exit_code; /* exit code to send to parrent */ - int wait_vfork; /* true while processing vfork() */ - pid_t pid; /* process id */ - task_t task; /* task id */ - cap_t cap; /* capability of the task */ - void *stack_base; /* pointer to stack */ - void *stack_saved; /* pointer to saved stack */ + struct list p_link; /* link for all processes */ + struct proc *p_parent; /* pointer to parent process */ + struct list p_children; /* list head of child processes */ + struct list p_sibling; /* link for sibling processes */ + struct list p_pid_link; /* link for pid hash */ + struct list p_task_link; /* link for task hash */ + struct list p_pgrp_link; /* link for process group */ + struct pgrp *p_pgrp; /* pointer to process group */ + int p_stat; /* process status S* */ + int p_exitcode; /* exit code to send to parrent */ + int p_vforked; /* true while processing vfork() */ + pid_t p_pid; /* process id */ + task_t p_task; /* task id */ + cap_t p_cap; /* capability of the task */ + void *p_stackbase; /* pointer to stack */ + void *p_stacksaved; /* pointer to saved stack */ }; /* @@ -101,29 +112,32 @@ extern struct list allproc; /* list of all processes */ extern struct proc *curproc; /* current (caller) process */ -extern pid_t pid_assign(void); extern struct proc *proc_find(pid_t); extern struct pgrp *pgrp_find(pid_t); extern struct proc *task_to_proc(task_t); -extern void proc_add(struct proc *); -extern void proc_remove(struct proc *); -extern void pgrp_add(struct pgrp *); -extern void pgrp_remove(struct pgrp *); -extern void table_init(void); -extern void pid_init(void); -extern void proc_cleanup(struct proc *); -extern void vfork_end(struct proc *); -extern int kill_pg(pid_t, int); -extern void tty_init(void); -extern int proc_getpid(struct msg *); -extern int proc_getppid(struct msg *); -extern int proc_getpgid(struct msg *); -extern int proc_setpgid(struct msg *); -extern int proc_fork(struct msg *); -extern int proc_exit(struct msg *); -extern int proc_stop(struct msg *); -extern int proc_waitpid(struct msg *); -extern int proc_kill(struct msg *); +extern pid_t pid_assign(void); +extern void proc_add(struct proc *); +extern void proc_remove(struct proc *); +extern void pgrp_add(struct pgrp *); +extern void pgrp_remove(struct pgrp *); +extern void table_init(void); +extern void pid_init(void); +extern void proc_cleanup(struct proc *); +extern void vfork_end(struct proc *); +extern int kill_pg(pid_t, int); +extern void tty_init(void); + +extern int proc_getpid(struct msg *); +extern int proc_getppid(struct msg *); +extern int proc_getpgid(struct msg *); +extern int proc_setpgid(struct msg *); +extern int proc_getsid(struct msg *); +extern int proc_setsid(struct msg *); +extern int proc_fork(struct msg *); +extern int proc_exit(struct msg *); +extern int proc_stop(struct msg *); +extern int proc_waitpid(struct msg *); +extern int proc_kill(struct msg *); #endif /* !_PROC_H */