[BACK]Return to proc.h CVS log [TXT][DIR] Up to [local] / prex-old / usr / server / proc

Annotation of prex-old/usr/server/proc/proc.h, Revision 1.1.1.1.2.1

1.1       nbrk        1: /*
                      2:  * Copyright (c) 2005-2007, Kohsuke Ohtani
                      3:  * All rights reserved.
                      4:  *
                      5:  * Redistribution and use in source and binary forms, with or without
                      6:  * modification, are permitted provided that the following conditions
                      7:  * are met:
                      8:  * 1. Redistributions of source code must retain the above copyright
                      9:  *    notice, this list of conditions and the following disclaimer.
                     10:  * 2. Redistributions in binary form must reproduce the above copyright
                     11:  *    notice, this list of conditions and the following disclaimer in the
                     12:  *    documentation and/or other materials provided with the distribution.
                     13:  * 3. Neither the name of the author nor the names of any co-contributors
                     14:  *    may be used to endorse or promote products derived from this software
                     15:  *    without specific prior written permission.
                     16:  *
                     17:  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
                     18:  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
                     19:  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
                     20:  * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
                     21:  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
                     22:  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
                     23:  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
                     24:  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
                     25:  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
                     26:  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
                     27:  * SUCH DAMAGE.
                     28:  */
                     29:
                     30: #ifndef _PROC_H
                     31: #define _PROC_H
                     32:
                     33: #include <sys/param.h>
                     34: #include <sys/types.h>
                     35: #include <sys/list.h>
                     36: #include <server/proc.h>
                     37: #include <server/stdmsg.h>
1.1.1.1.2.1! nbrk       38: #include <prex/capability.h>
1.1       nbrk       39:
                     40: #include <unistd.h>
                     41: #include <stdio.h>
                     42:
                     43: /* #define DEBUG_PROC 1 */
                     44:
                     45: #ifdef DEBUG_PROC
1.1.1.1.2.1! nbrk       46: #define DPRINTF(a) dprintf a
1.1       nbrk       47: #else
1.1.1.1.2.1! nbrk       48: #define DPRINTF(a)
1.1       nbrk       49: #endif
                     50:
                     51: #define PRIO_PROC      130             /* priority of process server */
                     52: #define PID_MAX                0x8000          /* max number for PID */
                     53:
                     54: #define ID_MAXBUCKETS  32
                     55: #define IDHASH(x)      ((x) & (ID_MAXBUCKETS - 1))
                     56:
1.1.1.1.2.1! nbrk       57: struct proc;
        !            58:
        !            59: /*
        !            60:  * Session
        !            61:  */
        !            62: struct session {
        !            63:        int             s_refcnt;       /* reference count */
        !            64:        struct proc     *s_leader;      /* session leader */
        !            65:        int             s_ttyhold;      /* true if hold tty */
        !            66: };
        !            67:
        !            68:
1.1       nbrk       69: /*
                     70:  * Process group
                     71:  */
                     72: struct pgrp {
1.1.1.1.2.1! nbrk       73:        struct list     pg_link;        /* link for pgid hash */
        !            74:        struct list     pg_members;     /* list head of processes */
        !            75:        struct session  *pg_session;    /* pointer to session */
        !            76:        pid_t           pg_pgid;        /* pgrp id */
1.1       nbrk       77: };
                     78:
                     79: /*
1.1.1.1.2.1! nbrk       80:  * Description of a process
1.1       nbrk       81:  */
                     82: struct proc {
1.1.1.1.2.1! nbrk       83:        struct list     p_link;         /* link for all processes */
        !            84:        struct proc     *p_parent;      /* pointer to parent process */
        !            85:        struct list     p_children;     /* list head of child processes */
        !            86:        struct list     p_sibling;      /* link for sibling processes */
        !            87:        struct list     p_pid_link;     /* link for pid hash */
        !            88:        struct list     p_task_link;    /* link for task hash */
        !            89:        struct list     p_pgrp_link;    /* link for process group */
        !            90:        struct pgrp     *p_pgrp;        /* pointer to process group */
        !            91:        int             p_stat;         /* process status S* */
        !            92:        int             p_exitcode;     /* exit code to send to parrent */
        !            93:        int             p_vforked;      /* true while processing vfork() */
        !            94:        pid_t           p_pid;          /* process id */
        !            95:        task_t          p_task;         /* task id */
        !            96:        cap_t           p_cap;          /* capability of the task */
        !            97:        void            *p_stackbase;   /* pointer to stack */
        !            98:        void            *p_stacksaved;  /* pointer to saved stack */
1.1       nbrk       99: };
                    100:
                    101: /*
                    102:  * stat codes
                    103:  */
                    104: #define SRUN   1       /* running */
                    105: #define SZOMB  2       /* process terminated but not waited for */
                    106: #define SSTOP  3       /* proces stopped */
                    107:
                    108: /*
                    109:  * Global variables.
                    110:  */
                    111: extern struct proc initproc;           /* process slot for init */
                    112: extern struct list allproc;            /* list of all processes */
                    113: extern struct proc *curproc;           /* current (caller) process */
                    114:
                    115: extern struct proc *proc_find(pid_t);
                    116: extern struct pgrp *pgrp_find(pid_t);
                    117: extern struct proc *task_to_proc(task_t);
1.1.1.1.2.1! nbrk      118:
        !           119: extern pid_t   pid_assign(void);
        !           120: extern void    proc_add(struct proc *);
        !           121: extern void    proc_remove(struct proc *);
        !           122: extern void    pgrp_add(struct pgrp *);
        !           123: extern void    pgrp_remove(struct pgrp *);
        !           124: extern void    table_init(void);
        !           125: extern void    pid_init(void);
        !           126: extern void    proc_cleanup(struct proc *);
        !           127: extern void    vfork_end(struct proc *);
        !           128: extern int     kill_pg(pid_t, int);
        !           129: extern void    tty_init(void);
        !           130:
        !           131: extern int     proc_getpid(struct msg *);
        !           132: extern int     proc_getppid(struct msg *);
        !           133: extern int     proc_getpgid(struct msg *);
        !           134: extern int     proc_setpgid(struct msg *);
        !           135: extern int     proc_getsid(struct msg *);
        !           136: extern int     proc_setsid(struct msg *);
        !           137: extern int     proc_fork(struct msg *);
        !           138: extern int     proc_exit(struct msg *);
        !           139: extern int     proc_stop(struct msg *);
        !           140: extern int     proc_waitpid(struct msg *);
        !           141: extern int     proc_kill(struct msg *);
1.1       nbrk      142:
                    143: #endif /* !_PROC_H */

CVSweb