PM: Convert K&R C -> ANSI C

Aditionally this removes all trailing whitespaces in pm server code
using: sed -i 's/[[:space:]]*$//' *.c

Change-Id: Ie44162fd56cd7042f4f0cc7bd7314b17ea128761
This commit is contained in:
Richard Sailer 2016-07-08 15:17:14 +02:00 committed by Lionel Sambuc
parent 1717959aeb
commit 637f688f0d
13 changed files with 204 additions and 164 deletions

View File

@ -27,7 +27,7 @@ static void set_realtimer(struct mproc *mp, struct itimerval *value);
static void cause_sigalrm(minix_timer_t *tp); static void cause_sigalrm(minix_timer_t *tp);
/*===========================================================================* /*===========================================================================*
* ticks_from_timeval * * ticks_from_timeval *
*===========================================================================*/ *===========================================================================*/
static clock_t ticks_from_timeval(tv) static clock_t ticks_from_timeval(tv)
struct timeval *tv; struct timeval *tv;
@ -48,7 +48,7 @@ struct timeval *tv;
* this be declared properly without combinatorial explosion of message * this be declared properly without combinatorial explosion of message
* types? * types?
*/ */
/* In any case, the following conversion must always round up. */ /* In any case, the following conversion must always round up. */
ticks = system_hz * (unsigned long) tv->tv_sec; ticks = system_hz * (unsigned long) tv->tv_sec;
@ -64,7 +64,7 @@ struct timeval *tv;
} }
/*===========================================================================* /*===========================================================================*
* timeval_from_ticks * * timeval_from_ticks *
*===========================================================================*/ *===========================================================================*/
static void timeval_from_ticks(tv, ticks) static void timeval_from_ticks(tv, ticks)
struct timeval *tv; struct timeval *tv;
@ -75,20 +75,21 @@ clock_t ticks;
} }
/*===========================================================================* /*===========================================================================*
* is_sane_timeval * * is_sane_timeval *
*===========================================================================*/ *===========================================================================*/
static int is_sane_timeval(tv) static int
struct timeval *tv; is_sane_timeval(struct timeval *tv)
{ {
/* This imposes a reasonable time value range for setitimer. */ /* This imposes a reasonable time value range for setitimer. */
return (tv->tv_sec >= 0 && tv->tv_sec <= MAX_SECS && return (tv->tv_sec >= 0 && tv->tv_sec <= MAX_SECS &&
tv->tv_usec >= 0 && tv->tv_usec < US); tv->tv_usec >= 0 && tv->tv_usec < US);
} }
/*===========================================================================* /*===========================================================================*
* do_itimer * * do_itimer *
*===========================================================================*/ *===========================================================================*/
int do_itimer() int
do_itimer(void)
{ {
struct itimerval ovalue, value; /* old and new interval timers */ struct itimerval ovalue, value; /* old and new interval timers */
int setval, getval; /* set and/or retrieve the values? */ int setval, getval; /* set and/or retrieve the values? */
@ -152,13 +153,10 @@ int do_itimer()
} }
/*===========================================================================* /*===========================================================================*
* getset_vtimer * * getset_vtimer *
*===========================================================================*/ *===========================================================================*/
static void getset_vtimer(rmp, which, value, ovalue) static void
struct mproc *rmp; getset_vtimer(struct mproc *rmp, int which, struct itimerval *value, struct itimerval *ovalue)
int which;
struct itimerval *value;
struct itimerval *ovalue;
{ {
clock_t newticks, *nptr; /* the new timer value, in ticks */ clock_t newticks, *nptr; /* the new timer value, in ticks */
clock_t oldticks, *optr; /* the old ticks value, in ticks */ clock_t oldticks, *optr; /* the old ticks value, in ticks */
@ -188,7 +186,7 @@ struct itimerval *ovalue;
/* If no timer is set, the interval must be zero. */ /* If no timer is set, the interval must be zero. */
if (newticks <= 0) if (newticks <= 0)
rmp->mp_interval[which] = 0; rmp->mp_interval[which] = 0;
else else
rmp->mp_interval[which] = rmp->mp_interval[which] =
ticks_from_timeval(&value->it_interval); ticks_from_timeval(&value->it_interval);
} }
@ -217,11 +215,10 @@ struct itimerval *ovalue;
} }
/*===========================================================================* /*===========================================================================*
* check_vtimer * * check_vtimer *
*===========================================================================*/ *===========================================================================*/
void check_vtimer(proc_nr, sig) void
int proc_nr; check_vtimer(int proc_nr, int sig)
int sig;
{ {
register struct mproc *rmp; register struct mproc *rmp;
int which, num; int which, num;
@ -243,11 +240,10 @@ int sig;
} }
/*===========================================================================* /*===========================================================================*
* get_realtimer * * get_realtimer *
*===========================================================================*/ *===========================================================================*/
static void get_realtimer(rmp, value) static void
struct mproc *rmp; get_realtimer(struct mproc *rmp, struct itimerval *value)
struct itimerval *value;
{ {
clock_t exptime; /* time at which alarm will expire */ clock_t exptime; /* time at which alarm will expire */
clock_t uptime; /* current system time */ clock_t uptime; /* current system time */
@ -276,11 +272,10 @@ struct itimerval *value;
} }
/*===========================================================================* /*===========================================================================*
* set_realtimer * * set_realtimer *
*===========================================================================*/ *===========================================================================*/
static void set_realtimer(rmp, value) static void
struct mproc *rmp; set_realtimer(struct mproc *rmp, struct itimerval *value)
struct itimerval *value;
{ {
clock_t ticks; /* New amount of ticks to the next alarm. */ clock_t ticks; /* New amount of ticks to the next alarm. */
clock_t interval; /* New amount of ticks for the alarm's interval. */ clock_t interval; /* New amount of ticks for the alarm's interval. */
@ -298,7 +293,7 @@ struct itimerval *value;
} }
/*===========================================================================* /*===========================================================================*
* set_alarm * * set_alarm *
*===========================================================================*/ *===========================================================================*/
void set_alarm(rmp, ticks) void set_alarm(rmp, ticks)
struct mproc *rmp; /* process that wants the alarm */ struct mproc *rmp; /* process that wants the alarm */
@ -314,7 +309,7 @@ clock_t ticks; /* how many ticks delay before the signal */
} }
/*===========================================================================* /*===========================================================================*
* cause_sigalrm * * cause_sigalrm *
*===========================================================================*/ *===========================================================================*/
static void cause_sigalrm(tp) static void cause_sigalrm(tp)
minix_timer_t *tp; minix_timer_t *tp;

View File

@ -310,7 +310,7 @@ do_proc_event_reply(void)
/* /*
* Publish a process event to interested subscribers. The event is determined * Publish a process event to interested subscribers. The event is determined
* from the process flags. In addition, if the event is a process exit, also * from the process flags. In addition, if the event is a process exit, also
* check if it is a subscribing service that died. * check if it is a subscribing service that died.
*/ */
void void

View File

@ -34,7 +34,8 @@
/*===========================================================================* /*===========================================================================*
* do_exec * * do_exec *
*===========================================================================*/ *===========================================================================*/
int do_exec() int
do_exec(void)
{ {
message m; message m;

View File

@ -41,7 +41,8 @@ static void cleanup(register struct mproc *rmp);
/*===========================================================================* /*===========================================================================*
* do_fork * * do_fork *
*===========================================================================*/ *===========================================================================*/
int do_fork() int
do_fork(void)
{ {
/* The process pointed to by 'mp' has forked. Create a child process. */ /* The process pointed to by 'mp' has forked. Create a child process. */
register struct mproc *rmp; /* pointer to parent */ register struct mproc *rmp; /* pointer to parent */
@ -56,7 +57,7 @@ int do_fork()
* way through is such a nuisance. * way through is such a nuisance.
*/ */
rmp = mp; rmp = mp;
if ((procs_in_use == NR_PROCS) || if ((procs_in_use == NR_PROCS) ||
(procs_in_use >= NR_PROCS-LAST_FEW && rmp->mp_effuid != 0)) (procs_in_use >= NR_PROCS-LAST_FEW && rmp->mp_effuid != 0))
{ {
printf("PM: warning, process table is full!\n"); printf("PM: warning, process table is full!\n");
@ -141,7 +142,8 @@ int do_fork()
/*===========================================================================* /*===========================================================================*
* do_srv_fork * * do_srv_fork *
*===========================================================================*/ *===========================================================================*/
int do_srv_fork() int
do_srv_fork(void)
{ {
/* The process pointed to by 'mp' has forked. Create a child process. */ /* The process pointed to by 'mp' has forked. Create a child process. */
register struct mproc *rmp; /* pointer to parent */ register struct mproc *rmp; /* pointer to parent */
@ -161,7 +163,7 @@ int do_srv_fork()
* way through is such a nuisance. * way through is such a nuisance.
*/ */
rmp = mp; rmp = mp;
if ((procs_in_use == NR_PROCS) || if ((procs_in_use == NR_PROCS) ||
(procs_in_use >= NR_PROCS-LAST_FEW && rmp->mp_effuid != 0)) (procs_in_use >= NR_PROCS-LAST_FEW && rmp->mp_effuid != 0))
{ {
printf("PM: warning, process table is full!\n"); printf("PM: warning, process table is full!\n");
@ -240,7 +242,8 @@ int do_srv_fork()
/*===========================================================================* /*===========================================================================*
* do_exit * * do_exit *
*===========================================================================*/ *===========================================================================*/
int do_exit() int
do_exit(void)
{ {
/* Perform the exit(status) system call. The real work is done by exit_proc(), /* Perform the exit(status) system call. The real work is done by exit_proc(),
* which is also called when a process is killed by a signal. System processes * which is also called when a process is killed by a signal. System processes
@ -261,10 +264,12 @@ int do_exit()
/*===========================================================================* /*===========================================================================*
* exit_proc * * exit_proc *
*===========================================================================*/ *===========================================================================*/
void exit_proc(rmp, exit_status, dump_core) void
register struct mproc *rmp; /* pointer to the process to be terminated */ exit_proc(
int exit_status; /* the process' exit status (for parent) */ register struct mproc *rmp, /* pointer to the process to be terminated */
int dump_core; /* flag indicating whether to dump core */ int exit_status, /* the process' exit status (for parent) */
int dump_core /* flag indicating whether to dump core */
)
{ {
/* A process is done. Release most of the process' possessions. If its /* A process is done. Release most of the process' possessions. If its
* parent is waiting, release the rest, else keep the process slot and * parent is waiting, release the rest, else keep the process slot and
@ -303,8 +308,8 @@ int dump_core; /* flag indicating whether to dump core */
rmp->mp_child_utime += user_time; /* add user time */ rmp->mp_child_utime += user_time; /* add user time */
rmp->mp_child_stime += sys_time; /* add system time */ rmp->mp_child_stime += sys_time; /* add system time */
/* Tell the kernel the process is no longer runnable to prevent it from /* Tell the kernel the process is no longer runnable to prevent it from
* being scheduled in between the following steps. Then tell VFS that it * being scheduled in between the following steps. Then tell VFS that it
* the process has exited and finally, clean up the process at the kernel. * the process has exited and finally, clean up the process at the kernel.
* This order is important so that VFS can tell drivers to cancel requests * This order is important so that VFS can tell drivers to cancel requests
* such as copying to/ from the exiting process, before it is gone. * such as copying to/ from the exiting process, before it is gone.
@ -370,7 +375,7 @@ int dump_core; /* flag indicating whether to dump core */
rmp->mp_flags |= EXITING; rmp->mp_flags |= EXITING;
/* Keep the process around until VFS is finished with it. */ /* Keep the process around until VFS is finished with it. */
rmp->mp_exitstatus = (char) exit_status; rmp->mp_exitstatus = (char) exit_status;
/* For normal exits, try to notify the parent as soon as possible. /* For normal exits, try to notify the parent as soon as possible.
@ -426,7 +431,7 @@ void exit_restart(struct mproc *rmp)
*/ */
printf("PM: The scheduler did not want to give up " printf("PM: The scheduler did not want to give up "
"scheduling %s, ret=%d.\n", rmp->mp_name, r); "scheduling %s, ret=%d.\n", rmp->mp_name, r);
} }
/* sched_stop is either called when the process is exiting or it is /* sched_stop is either called when the process is exiting or it is
* being moved between schedulers. If it is being moved between * being moved between schedulers. If it is being moved between
@ -466,11 +471,12 @@ void exit_restart(struct mproc *rmp)
/*===========================================================================* /*===========================================================================*
* do_wait4 * * do_wait4 *
*===========================================================================*/ *===========================================================================*/
int do_wait4() int
do_wait4(void)
{ {
/* A process wants to wait for a child to terminate. If a child is already /* A process wants to wait for a child to terminate. If a child is already
* waiting, go clean it up and let this WAIT4 call terminate. Otherwise, * waiting, go clean it up and let this WAIT4 call terminate. Otherwise,
* really wait. * really wait.
* A process calling WAIT4 never gets a reply in the usual way at the end * A process calling WAIT4 never gets a reply in the usual way at the end
* of the main loop (unless WNOHANG is set or no qualifying child exists). * of the main loop (unless WNOHANG is set or no qualifying child exists).
* If a child has already exited, the routine tell_parent() sends the reply * If a child has already exited, the routine tell_parent() sends the reply
@ -560,9 +566,11 @@ int do_wait4()
/*===========================================================================* /*===========================================================================*
* wait_test * * wait_test *
*===========================================================================*/ *===========================================================================*/
int wait_test(rmp, child) int
struct mproc *rmp; /* process that may be waiting */ wait_test(
struct mproc *child; /* process that may be waited for */ struct mproc *rmp, /* process that may be waiting */
struct mproc *child /* process that may be waited for */
)
{ {
/* See if a parent or tracer process is waiting for a child process. /* See if a parent or tracer process is waiting for a child process.
* A tracer is considered to be a pseudo-parent. * A tracer is considered to be a pseudo-parent.
@ -582,8 +590,8 @@ struct mproc *child; /* process that may be waited for */
/*===========================================================================* /*===========================================================================*
* zombify * * zombify *
*===========================================================================*/ *===========================================================================*/
static void zombify(rmp) static void
struct mproc *rmp; zombify(struct mproc *rmp)
{ {
/* Zombify a process. First check if the exiting process is traced by a process /* Zombify a process. First check if the exiting process is traced by a process
* other than its parent; if so, the tracer must be notified about the exit * other than its parent; if so, the tracer must be notified about the exit
@ -618,9 +626,11 @@ struct mproc *rmp;
/*===========================================================================* /*===========================================================================*
* check_parent * * check_parent *
*===========================================================================*/ *===========================================================================*/
static void check_parent(child, try_cleanup) static void
struct mproc *child; /* tells which process is exiting */ check_parent(
int try_cleanup; /* clean up the child when done? */ struct mproc *child, /* tells which process is exiting */
int try_cleanup /* clean up the child when done? */
)
{ {
/* We would like to inform the parent of an exiting child about the child's /* We would like to inform the parent of an exiting child about the child's
* death. If the parent is waiting for the child, tell it immediately; * death. If the parent is waiting for the child, tell it immediately;
@ -718,8 +728,10 @@ static int tell_parent(struct mproc *child, vir_bytes addr)
/*===========================================================================* /*===========================================================================*
* tell_tracer * * tell_tracer *
*===========================================================================*/ *===========================================================================*/
static void tell_tracer(child) static void
struct mproc *child; /* tells which process is exiting */ tell_tracer(
struct mproc *child /* tells which process is exiting */
)
{ {
int mp_tracer; int mp_tracer;
struct mproc *tracer; struct mproc *tracer;
@ -744,8 +756,10 @@ struct mproc *child; /* tells which process is exiting */
/*===========================================================================* /*===========================================================================*
* tracer_died * * tracer_died *
*===========================================================================*/ *===========================================================================*/
static void tracer_died(child) static void
struct mproc *child; /* process being traced */ tracer_died(
struct mproc *child /* process being traced */
)
{ {
/* The process that was tracing the given child, has died for some reason. /* The process that was tracing the given child, has died for some reason.
* This is really the tracer's fault, but we can't let INIT deal with this. * This is really the tracer's fault, but we can't let INIT deal with this.
@ -778,8 +792,10 @@ struct mproc *child; /* process being traced */
/*===========================================================================* /*===========================================================================*
* cleanup * * cleanup *
*===========================================================================*/ *===========================================================================*/
static void cleanup(rmp) static void
register struct mproc *rmp; /* tells which process is exiting */ cleanup(
register struct mproc *rmp /* tells which process is exiting */
)
{ {
/* Release the process table entry and reinitialize some field. */ /* Release the process table entry and reinitialize some field. */
rmp->mp_pid = 0; rmp->mp_pid = 0;

View File

@ -15,7 +15,8 @@
/*===========================================================================* /*===========================================================================*
* do_get * * do_get *
*===========================================================================*/ *===========================================================================*/
int do_get() int
do_get(void)
{ {
/* Handle PM_GETUID, PM_GETGID, PM_GETGROUPS, PM_GETPID, PM_GETPGRP, PM_GETSID, /* Handle PM_GETUID, PM_GETGID, PM_GETGROUPS, PM_GETPID, PM_GETPGRP, PM_GETSID,
* PM_ISSETUGID. * PM_ISSETUGID.
@ -82,7 +83,7 @@ int do_get()
default: default:
r = EINVAL; r = EINVAL;
break; break;
} }
return(r); return(r);
} }
@ -90,7 +91,8 @@ int do_get()
/*===========================================================================* /*===========================================================================*
* do_set * * do_set *
*===========================================================================*/ *===========================================================================*/
int do_set() int
do_set(void)
{ {
/* Handle PM_SETUID, PM_SETEUID, PM_SETGID, PM_SETGROUPS, PM_SETEGID, and /* Handle PM_SETUID, PM_SETEUID, PM_SETGID, PM_SETGROUPS, PM_SETEGID, and
* SETSID. These calls have in common that, if successful, they will be * SETSID. These calls have in common that, if successful, they will be
@ -173,7 +175,7 @@ int do_set()
ngroups = m_in.m_lc_pm_groups.num; ngroups = m_in.m_lc_pm_groups.num;
if (ngroups > NGROUPS_MAX || ngroups < 0) if (ngroups > NGROUPS_MAX || ngroups < 0)
return(EINVAL); return(EINVAL);
if (ngroups > 0 && m_in.m_lc_pm_groups.ptr == 0) if (ngroups > 0 && m_in.m_lc_pm_groups.ptr == 0)
@ -182,7 +184,7 @@ int do_set()
r = sys_datacopy(who_e, m_in.m_lc_pm_groups.ptr, SELF, r = sys_datacopy(who_e, m_in.m_lc_pm_groups.ptr, SELF,
(vir_bytes) rmp->mp_sgroups, (vir_bytes) rmp->mp_sgroups,
ngroups * sizeof(gid_t)); ngroups * sizeof(gid_t));
if (r != OK) if (r != OK)
return(r); return(r);
for (i = 0; i < ngroups; i++) { for (i = 0; i < ngroups; i++) {

View File

@ -47,7 +47,8 @@ static int sef_cb_init_fresh(int type, sef_init_info_t *info);
/*===========================================================================* /*===========================================================================*
* main * * main *
*===========================================================================*/ *===========================================================================*/
int main() int
main(void)
{ {
/* Main routine of the process manager. */ /* Main routine of the process manager. */
unsigned int call_index; unsigned int call_index;
@ -112,7 +113,8 @@ int main()
/*===========================================================================* /*===========================================================================*
* sef_local_startup * * sef_local_startup *
*===========================================================================*/ *===========================================================================*/
static void sef_local_startup() static void
sef_local_startup(void)
{ {
/* Register init callbacks. */ /* Register init callbacks. */
sef_setcb_init_fresh(sef_cb_init_fresh); sef_setcb_init_fresh(sef_cb_init_fresh);
@ -137,7 +139,7 @@ static int sef_cb_init_fresh(int UNUSED(type), sef_init_info_t *UNUSED(info))
static char core_sigs[] = { SIGQUIT, SIGILL, SIGTRAP, SIGABRT, static char core_sigs[] = { SIGQUIT, SIGILL, SIGTRAP, SIGABRT,
SIGEMT, SIGFPE, SIGBUS, SIGSEGV }; SIGEMT, SIGFPE, SIGBUS, SIGSEGV };
static char ign_sigs[] = { SIGCHLD, SIGWINCH, SIGCONT, SIGINFO }; static char ign_sigs[] = { SIGCHLD, SIGWINCH, SIGCONT, SIGINFO };
static char noign_sigs[] = { SIGILL, SIGTRAP, SIGEMT, SIGFPE, static char noign_sigs[] = { SIGILL, SIGTRAP, SIGEMT, SIGFPE,
SIGBUS, SIGSEGV }; SIGBUS, SIGSEGV };
register struct mproc *rmp; register struct mproc *rmp;
register char *sig_ptr; register char *sig_ptr;
@ -169,10 +171,10 @@ static int sef_cb_init_fresh(int UNUSED(type), sef_init_info_t *UNUSED(info))
if ((s=sys_getmonparams(monitor_params, sizeof(monitor_params))) != OK) if ((s=sys_getmonparams(monitor_params, sizeof(monitor_params))) != OK)
panic("get monitor params failed: %d", s); panic("get monitor params failed: %d", s);
/* Initialize PM's process table. Request a copy of the system image table /* Initialize PM's process table. Request a copy of the system image table
* that is defined at the kernel level to see which slots to fill in. * that is defined at the kernel level to see which slots to fill in.
*/ */
if (OK != (s=sys_getimage(image))) if (OK != (s=sys_getimage(image)))
panic("couldn't get image table: %d", s); panic("couldn't get image table: %d", s);
procs_in_use = 0; /* start populating table */ procs_in_use = 0; /* start populating table */
for (ip = &image[0]; ip < &image[NR_BOOT_PROCS]; ip++) { for (ip = &image[0]; ip < &image[NR_BOOT_PROCS]; ip++) {
@ -180,20 +182,20 @@ static int sef_cb_init_fresh(int UNUSED(type), sef_init_info_t *UNUSED(info))
procs_in_use += 1; /* found user process */ procs_in_use += 1; /* found user process */
/* Set process details found in the image table. */ /* Set process details found in the image table. */
rmp = &mproc[ip->proc_nr]; rmp = &mproc[ip->proc_nr];
strlcpy(rmp->mp_name, ip->proc_name, PROC_NAME_LEN); strlcpy(rmp->mp_name, ip->proc_name, PROC_NAME_LEN);
(void) sigemptyset(&rmp->mp_ignore); (void) sigemptyset(&rmp->mp_ignore);
(void) sigemptyset(&rmp->mp_sigmask); (void) sigemptyset(&rmp->mp_sigmask);
(void) sigemptyset(&rmp->mp_catch); (void) sigemptyset(&rmp->mp_catch);
if (ip->proc_nr == INIT_PROC_NR) { /* user process */ if (ip->proc_nr == INIT_PROC_NR) { /* user process */
/* INIT is root, we make it father of itself. This is /* INIT is root, we make it father of itself. This is
* not really OK, INIT should have no father, i.e. * not really OK, INIT should have no father, i.e.
* a father with pid NO_PID. But PM currently assumes * a father with pid NO_PID. But PM currently assumes
* that mp_parent always points to a valid slot number. * that mp_parent always points to a valid slot number.
*/ */
rmp->mp_parent = INIT_PROC_NR; rmp->mp_parent = INIT_PROC_NR;
rmp->mp_procgrp = rmp->mp_pid = INIT_PID; rmp->mp_procgrp = rmp->mp_pid = INIT_PID;
rmp->mp_flags |= IN_USE; rmp->mp_flags |= IN_USE;
/* Set scheduling info */ /* Set scheduling info */
rmp->mp_scheduler = KERNEL; rmp->mp_scheduler = KERNEL;
@ -246,9 +248,11 @@ static int sef_cb_init_fresh(int UNUSED(type), sef_init_info_t *UNUSED(info))
/*===========================================================================* /*===========================================================================*
* reply * * reply *
*===========================================================================*/ *===========================================================================*/
void reply(proc_nr, result) void
int proc_nr; /* process to reply to */ reply(
int result; /* result of call (usually OK or error #) */ int proc_nr, /* process to reply to */
int result /* result of call (usually OK or error #) */
)
{ {
/* Send a reply to a user process. System calls may occasionally fill in other /* Send a reply to a user process. System calls may occasionally fill in other
* fields, this is only for the main return value and for sending the reply. * fields, this is only for the main return value and for sending the reply.
@ -270,14 +274,16 @@ int result; /* result of call (usually OK or error #) */
/*===========================================================================* /*===========================================================================*
* get_nice_value * * get_nice_value *
*===========================================================================*/ *===========================================================================*/
static int get_nice_value(queue) static int
int queue; /* store mem chunks here */ get_nice_value(
int queue /* store mem chunks here */
)
{ {
/* Processes in the boot image have a priority assigned. The PM doesn't know /* Processes in the boot image have a priority assigned. The PM doesn't know
* about priorities, but uses 'nice' values instead. The priority is between * about priorities, but uses 'nice' values instead. The priority is between
* MIN_USER_Q and MAX_USER_Q. We have to scale between PRIO_MIN and PRIO_MAX. * MIN_USER_Q and MAX_USER_Q. We have to scale between PRIO_MIN and PRIO_MAX.
*/ */
int nice_val = (queue - USER_Q) * (PRIO_MAX-PRIO_MIN+1) / int nice_val = (queue - USER_Q) * (PRIO_MAX-PRIO_MIN+1) /
(MIN_USER_Q-MAX_USER_Q+1); (MIN_USER_Q-MAX_USER_Q+1);
if (nice_val > PRIO_MAX) nice_val = PRIO_MAX; /* shouldn't happen */ if (nice_val > PRIO_MAX) nice_val = PRIO_MAX; /* shouldn't happen */
if (nice_val < PRIO_MIN) nice_val = PRIO_MIN; /* shouldn't happen */ if (nice_val < PRIO_MIN) nice_val = PRIO_MIN; /* shouldn't happen */
@ -287,7 +293,8 @@ int queue; /* store mem chunks here */
/*===========================================================================* /*===========================================================================*
* handle_vfs_reply * * handle_vfs_reply *
*===========================================================================*/ *===========================================================================*/
static void handle_vfs_reply() static void
handle_vfs_reply(void)
{ {
struct mproc *rmp; struct mproc *rmp;
endpoint_t proc_e; endpoint_t proc_e;

View File

@ -9,7 +9,8 @@
/*===========================================================================* /*===========================================================================*
* do_setmcontext * * do_setmcontext *
*===========================================================================*/ *===========================================================================*/
int do_setmcontext() int
do_setmcontext(void)
{ {
return sys_setmcontext(who_e, m_in.m_lc_pm_mcontext.ctx); return sys_setmcontext(who_e, m_in.m_lc_pm_mcontext.ctx);
} }
@ -18,7 +19,8 @@ int do_setmcontext()
/*===========================================================================* /*===========================================================================*
* do_getmcontext * * do_getmcontext *
*===========================================================================*/ *===========================================================================*/
int do_getmcontext() int
do_getmcontext(void)
{ {
return sys_getmcontext(who_e, m_in.m_lc_pm_mcontext.ctx); return sys_getmcontext(who_e, m_in.m_lc_pm_mcontext.ctx);
} }

View File

@ -68,7 +68,8 @@ unsigned long calls_stats[NR_PM_CALLS];
/*===========================================================================* /*===========================================================================*
* do_sysuname * * do_sysuname *
*===========================================================================*/ *===========================================================================*/
int do_sysuname() int
do_sysuname(void)
{ {
/* Set or get uname strings. */ /* Set or get uname strings. */
int r; int r;
@ -103,7 +104,8 @@ int do_sysuname()
/*===========================================================================* /*===========================================================================*
* do_getsysinfo * * do_getsysinfo *
*===========================================================================*/ *===========================================================================*/
int do_getsysinfo() int
do_getsysinfo(void)
{ {
vir_bytes src_addr, dst_addr; vir_bytes src_addr, dst_addr;
size_t len; size_t len;
@ -128,7 +130,7 @@ int do_getsysinfo()
case SI_CALL_STATS: case SI_CALL_STATS:
src_addr = (vir_bytes) calls_stats; src_addr = (vir_bytes) calls_stats;
len = sizeof(calls_stats); len = sizeof(calls_stats);
break; break;
#endif #endif
default: default:
return(EINVAL); return(EINVAL);
@ -183,7 +185,8 @@ int do_getepinfo(void)
/*===========================================================================* /*===========================================================================*
* do_reboot * * do_reboot *
*===========================================================================*/ *===========================================================================*/
int do_reboot() int
do_reboot(void)
{ {
message m; message m;
@ -204,7 +207,7 @@ int do_reboot()
/* Order matters here. When VFS is told to reboot, it exits all its /* Order matters here. When VFS is told to reboot, it exits all its
* processes, and then would be confused if they're exited again by * processes, and then would be confused if they're exited again by
* SIGKILL. So first kill, then reboot. * SIGKILL. So first kill, then reboot.
*/ */
check_sig(-1, SIGKILL, FALSE /* ksig*/); /* kill all users except init */ check_sig(-1, SIGKILL, FALSE /* ksig*/); /* kill all users except init */
@ -222,7 +225,8 @@ int do_reboot()
/*===========================================================================* /*===========================================================================*
* do_getsetpriority * * do_getsetpriority *
*===========================================================================*/ *===========================================================================*/
int do_getsetpriority() int
do_getsetpriority(void)
{ {
int r, arg_which, arg_who, arg_pri; int r, arg_which, arg_who, arg_pri;
struct mproc *rmp; struct mproc *rmp;
@ -255,7 +259,7 @@ int do_getsetpriority()
/* Only root is allowed to reduce the nice level. */ /* Only root is allowed to reduce the nice level. */
if (rmp->mp_nice > arg_pri && mp->mp_effuid != SUPER_USER) if (rmp->mp_nice > arg_pri && mp->mp_effuid != SUPER_USER)
return(EACCES); return(EACCES);
/* We're SET, and it's allowed. /* We're SET, and it's allowed.
* *
* The value passed in is currently between PRIO_MIN and PRIO_MAX. * The value passed in is currently between PRIO_MIN and PRIO_MAX.
@ -305,8 +309,8 @@ int do_svrctl(void)
size_t copy_len; size_t copy_len;
/* Copy sysgetenv structure to PM. */ /* Copy sysgetenv structure to PM. */
if (sys_datacopy(who_e, ptr, SELF, (vir_bytes) &sysgetenv, if (sys_datacopy(who_e, ptr, SELF, (vir_bytes) &sysgetenv,
sizeof(sysgetenv)) != OK) return(EFAULT); sizeof(sysgetenv)) != OK) return(EFAULT);
/* Set a param override? */ /* Set a param override? */
if (req == PMSETPARAM || req == OPMSETPARAM) { if (req == PMSETPARAM || req == OPMSETPARAM) {
@ -318,7 +322,7 @@ int do_svrctl(void)
|| sysgetenv.vallen >= || sysgetenv.vallen >=
sizeof(local_param_overrides[local_params].value)) sizeof(local_param_overrides[local_params].value))
return EINVAL; return EINVAL;
if ((s = sys_datacopy(who_e, (vir_bytes) sysgetenv.key, if ((s = sys_datacopy(who_e, (vir_bytes) sysgetenv.key,
SELF, (vir_bytes) local_param_overrides[local_params].name, SELF, (vir_bytes) local_param_overrides[local_params].name,
sysgetenv.keylen)) != OK) sysgetenv.keylen)) != OK)
@ -338,7 +342,7 @@ int do_svrctl(void)
if (sysgetenv.keylen == 0) { /* copy all parameters */ if (sysgetenv.keylen == 0) { /* copy all parameters */
val_start = monitor_params; val_start = monitor_params;
val_len = sizeof(monitor_params); val_len = sizeof(monitor_params);
} }
else { /* lookup value for key */ else { /* lookup value for key */
int p; int p;
/* Try to get a copy of the requested key. */ /* Try to get a copy of the requested key. */
@ -367,8 +371,8 @@ int do_svrctl(void)
return E2BIG; return E2BIG;
/* Value found, make the actual copy (as far as possible). */ /* Value found, make the actual copy (as far as possible). */
copy_len = MIN(val_len, sysgetenv.vallen); copy_len = MIN(val_len, sysgetenv.vallen);
if ((s=sys_datacopy(SELF, (vir_bytes) val_start, if ((s=sys_datacopy(SELF, (vir_bytes) val_start,
who_e, (vir_bytes) sysgetenv.val, copy_len)) != OK) who_e, (vir_bytes) sysgetenv.val, copy_len)) != OK)
return(s); return(s);

View File

@ -22,13 +22,13 @@ void sched_init(void)
struct mproc *trmp; struct mproc *trmp;
endpoint_t parent_e; endpoint_t parent_e;
int proc_nr, s; int proc_nr, s;
for (proc_nr=0, trmp=mproc; proc_nr < NR_PROCS; proc_nr++, trmp++) { for (proc_nr=0, trmp=mproc; proc_nr < NR_PROCS; proc_nr++, trmp++) {
/* Don't take over system processes. When the system starts, /* Don't take over system processes. When the system starts,
* init is blocked on RTS_NO_QUANTUM until PM assigns a * init is blocked on RTS_NO_QUANTUM until PM assigns a
* scheduler, from which other. Given that all other user * scheduler, from which other. Given that all other user
* processes are forked from init and system processes are * processes are forked from init and system processes are
* managed by RS, there should be no other process that needs * managed by RS, there should be no other process that needs
* to be assigned a scheduler here */ * to be assigned a scheduler here */
if (trmp->mp_flags & IN_USE && !(trmp->mp_flags & PRIV_PROC)) { if (trmp->mp_flags & IN_USE && !(trmp->mp_flags & PRIV_PROC)) {
assert(_ENDPOINT_P(trmp->mp_endpoint) == INIT_PROC_NR); assert(_ENDPOINT_P(trmp->mp_endpoint) == INIT_PROC_NR);
@ -62,10 +62,10 @@ int sched_start_user(endpoint_t ep, struct mproc *rmp)
if ((rv = nice_to_priority(rmp->mp_nice, &maxprio)) != OK) { if ((rv = nice_to_priority(rmp->mp_nice, &maxprio)) != OK) {
return rv; return rv;
} }
/* scheduler must know the parent, which is not the case for a child /* scheduler must know the parent, which is not the case for a child
* of a system process created by a regular fork; in this case the * of a system process created by a regular fork; in this case the
* scheduler should inherit settings from init rather than the real * scheduler should inherit settings from init rather than the real
* parent * parent
*/ */
if (mproc[rmp->mp_parent].mp_flags & PRIV_PROC) { if (mproc[rmp->mp_parent].mp_flags & PRIV_PROC) {
@ -74,7 +74,7 @@ int sched_start_user(endpoint_t ep, struct mproc *rmp)
} else { } else {
inherit_from = mproc[rmp->mp_parent].mp_endpoint; inherit_from = mproc[rmp->mp_parent].mp_endpoint;
} }
/* inherit quantum */ /* inherit quantum */
return sched_inherit(ep, /* scheduler_e */ return sched_inherit(ep, /* scheduler_e */
rmp->mp_endpoint, /* schedulee_e */ rmp->mp_endpoint, /* schedulee_e */

View File

@ -367,7 +367,7 @@ int process_ksig(endpoint_t proc_nr_e, int signo)
assert(!(rmp->mp_flags & DELAY_CALL)); assert(!(rmp->mp_flags & DELAY_CALL));
} }
/* See if the process is still alive */ /* See if the process is still alive */
if ((mproc[proc_nr].mp_flags & (IN_USE | EXITING)) == IN_USE) { if ((mproc[proc_nr].mp_flags & (IN_USE | EXITING)) == IN_USE) {
return OK; /* signal has been delivered */ return OK; /* signal has been delivered */
@ -380,22 +380,24 @@ int process_ksig(endpoint_t proc_nr_e, int signo)
/*===========================================================================* /*===========================================================================*
* sig_proc * * sig_proc *
*===========================================================================*/ *===========================================================================*/
void sig_proc(rmp, signo, trace, ksig) void
register struct mproc *rmp; /* pointer to the process to be signaled */ sig_proc(
int signo; /* signal to send to process (1 to _NSIG-1) */ register struct mproc *rmp, /* pointer to the process to be signaled */
int trace; /* pass signal to tracer first? */ int signo, /* signal to send to process (1 to _NSIG-1) */
int ksig; /* non-zero means signal comes from kernel */ int trace, /* pass signal to tracer first? */
int ksig /* non-zero means signal comes from kernel */
)
{ {
/* Send a signal to a process. Check to see if the signal is to be caught, /* Send a signal to a process. Check to see if the signal is to be caught,
* ignored, tranformed into a message (for system processes) or blocked. * ignored, tranformed into a message (for system processes) or blocked.
* - If the signal is to be transformed into a message, request the KERNEL to * - If the signal is to be transformed into a message, request the KERNEL to
* send the target process a system notification with the pending signal as an * send the target process a system notification with the pending signal as an
* argument. * argument.
* - If the signal is to be caught, request the KERNEL to push a sigcontext * - If the signal is to be caught, request the KERNEL to push a sigcontext
* structure and a sigframe structure onto the catcher's stack. Also, KERNEL * structure and a sigframe structure onto the catcher's stack. Also, KERNEL
* will reset the program counter and stack pointer, so that when the process * will reset the program counter and stack pointer, so that when the process
* next runs, it will be executing the signal handler. When the signal handler * next runs, it will be executing the signal handler. When the signal handler
* returns, sigreturn(2) will be called. Then KERNEL will restore the signal * returns, sigreturn(2) will be called. Then KERNEL will restore the signal
* context from the sigcontext structure. * context from the sigcontext structure.
* If there is insufficient stack space, kill the process. * If there is insufficient stack space, kill the process.
*/ */
@ -482,7 +484,7 @@ int ksig; /* non-zero means signal comes from kernel */
sigismember(&rmp->mp_ignore, signo) || sigismember(&rmp->mp_ignore, signo) ||
sigismember(&rmp->mp_sigmask, signo)); sigismember(&rmp->mp_sigmask, signo));
if (!badignore && sigismember(&rmp->mp_ignore, signo)) { if (!badignore && sigismember(&rmp->mp_ignore, signo)) {
/* Signal should be ignored. */ /* Signal should be ignored. */
return; return;
} }
@ -540,9 +542,11 @@ int ksig; /* non-zero means signal comes from kernel */
/*===========================================================================* /*===========================================================================*
* sig_proc_exit * * sig_proc_exit *
*===========================================================================*/ *===========================================================================*/
static void sig_proc_exit(rmp, signo) static void
struct mproc *rmp; /* process that must exit */ sig_proc_exit(
int signo; /* signal that caused termination */ struct mproc *rmp, /* process that must exit */
int signo /* signal that caused termination */
)
{ {
rmp->mp_sigstatus = (char) signo; rmp->mp_sigstatus = (char) signo;
if (sigismember(&core_sset, signo)) { if (sigismember(&core_sset, signo)) {
@ -644,8 +648,8 @@ int ksig; /* non-zero means signal comes from kernel */
/*===========================================================================* /*===========================================================================*
* check_pending * * check_pending *
*===========================================================================*/ *===========================================================================*/
void check_pending(rmp) void
register struct mproc *rmp; check_pending(register struct mproc *rmp)
{ {
/* Check to see if any pending signals have been unblocked. Deliver as many /* Check to see if any pending signals have been unblocked. Deliver as many
* of them as we can, until we have to wait for a reply from VFS first. * of them as we can, until we have to wait for a reply from VFS first.
@ -680,8 +684,8 @@ register struct mproc *rmp;
/*===========================================================================* /*===========================================================================*
* restart_sigs * * restart_sigs *
*===========================================================================*/ *===========================================================================*/
void restart_sigs(rmp) void
struct mproc *rmp; restart_sigs(struct mproc *rmp)
{ {
/* VFS has replied to a request from us; do signal-related work. /* VFS has replied to a request from us; do signal-related work.
*/ */
@ -712,8 +716,10 @@ struct mproc *rmp;
/*===========================================================================* /*===========================================================================*
* unpause * * unpause *
*===========================================================================*/ *===========================================================================*/
static int unpause(rmp) static int
struct mproc *rmp; /* which process */ unpause(
struct mproc *rmp /* which process */
)
{ {
/* A signal is to be sent to a process. If that process is hanging on a /* A signal is to be sent to a process. If that process is hanging on a
* system call, the system call must be terminated with EINTR. First check if * system call, the system call must be terminated with EINTR. First check if
@ -766,9 +772,11 @@ struct mproc *rmp; /* which process */
/*===========================================================================* /*===========================================================================*
* sig_send * * sig_send *
*===========================================================================*/ *===========================================================================*/
static int sig_send(rmp, signo) static int
struct mproc *rmp; /* what process to spawn a signal handler in */ sig_send(
int signo; /* signal to send to process (1 to _NSIG-1) */ struct mproc *rmp, /* what process to spawn a signal handler in */
int signo /* signal to send to process (1 to _NSIG-1) */
)
{ {
/* The process is supposed to catch this signal. Spawn a signal handler. /* The process is supposed to catch this signal. Spawn a signal handler.
* Return TRUE if this succeeded, FALSE otherwise. * Return TRUE if this succeeded, FALSE otherwise.

View File

@ -18,7 +18,8 @@
/*===========================================================================* /*===========================================================================*
* do_gettime * * do_gettime *
*===========================================================================*/ *===========================================================================*/
int do_gettime() int
do_gettime(void)
{ {
clock_t ticks, realtime, clock; clock_t ticks, realtime, clock;
time_t boottime; time_t boottime;
@ -48,7 +49,8 @@ int do_gettime()
/*===========================================================================* /*===========================================================================*
* do_getres * * do_getres *
*===========================================================================*/ *===========================================================================*/
int do_getres() int
do_getres(void)
{ {
switch (m_in.m_lc_pm_time.clk_id) { switch (m_in.m_lc_pm_time.clk_id) {
case CLOCK_REALTIME: case CLOCK_REALTIME:
@ -65,11 +67,12 @@ int do_getres()
/*===========================================================================* /*===========================================================================*
* do_settime * * do_settime *
*===========================================================================*/ *===========================================================================*/
int do_settime() int
do_settime(void)
{ {
int s; int s;
if (mp->mp_effuid != SUPER_USER) { if (mp->mp_effuid != SUPER_USER) {
return(EPERM); return(EPERM);
} }
@ -87,7 +90,8 @@ int do_settime()
/*===========================================================================* /*===========================================================================*
* do_time * * do_time *
*===========================================================================*/ *===========================================================================*/
int do_time() int
do_time(void)
{ {
/* Perform the time(tp) system call. */ /* Perform the time(tp) system call. */
struct timespec tv; struct timespec tv;
@ -102,19 +106,20 @@ int do_time()
/*===========================================================================* /*===========================================================================*
* do_stime * * do_stime *
*===========================================================================*/ *===========================================================================*/
int do_stime() int
do_stime(void)
{ {
/* Perform the stime(tp) system call. Retrieve the system's uptime (ticks /* Perform the stime(tp) system call. Retrieve the system's uptime (ticks
* since boot) and pass the new time in seconds at system boot to the kernel. * since boot) and pass the new time in seconds at system boot to the kernel.
*/ */
clock_t uptime, realtime; clock_t uptime, realtime;
time_t boottime; time_t boottime;
int s; int s;
if (mp->mp_effuid != SUPER_USER) { if (mp->mp_effuid != SUPER_USER) {
return(EPERM); return(EPERM);
} }
if ( (s=getuptime(&uptime, &realtime, &boottime)) != OK) if ( (s=getuptime(&uptime, &realtime, &boottime)) != OK)
panic("do_stime couldn't get uptime: %d", s); panic("do_stime couldn't get uptime: %d", s);
boottime = m_in.m_lc_pm_time.sec - (realtime/system_hz); boottime = m_in.m_lc_pm_time.sec - (realtime/system_hz);

View File

@ -1,30 +1,30 @@
/* This file handles the process manager's part of debugging, using the /* This file handles the process manager's part of debugging, using the
* ptrace system call. Most of the commands are passed on to the system * ptrace system call. Most of the commands are passed on to the system
* task for completion. * task for completion.
* *
* The debugging commands available are: * The debugging commands available are:
* T_STOP stop the process * T_STOP stop the process
* T_OK enable tracing by parent for this process * T_OK enable tracing by parent for this process
* T_GETINS return value from instruction space * T_GETINS return value from instruction space
* T_GETDATA return value from data space * T_GETDATA return value from data space
* T_GETUSER return value from user process table * T_GETUSER return value from user process table
* T_SETINS set value in instruction space * T_SETINS set value in instruction space
* T_SETDATA set value in data space * T_SETDATA set value in data space
* T_SETUSER set value in user process table * T_SETUSER set value in user process table
* T_RESUME resume execution * T_RESUME resume execution
* T_EXIT exit * T_EXIT exit
* T_STEP set trace bit * T_STEP set trace bit
* T_SYSCALL trace system call * T_SYSCALL trace system call
* T_ATTACH attach to an existing process * T_ATTACH attach to an existing process
* T_DETACH detach from a traced process * T_DETACH detach from a traced process
* T_SETOPT set trace options * T_SETOPT set trace options
* T_GETRANGE get range of values * T_GETRANGE get range of values
* T_SETRANGE set range of values * T_SETRANGE set range of values
* *
* The T_OK, T_ATTACH, T_EXIT, and T_SETOPT commands are handled here, and the * The T_OK, T_ATTACH, T_EXIT, and T_SETOPT commands are handled here, and the
* T_RESUME, T_STEP, T_SYSCALL, and T_DETACH commands are partially handled * T_RESUME, T_STEP, T_SYSCALL, and T_DETACH commands are partially handled
* here and completed by the system task. The rest are handled entirely by the * here and completed by the system task. The rest are handled entirely by the
* system task. * system task.
*/ */
#include "pm.h" #include "pm.h"
@ -38,7 +38,8 @@
/*===========================================================================* /*===========================================================================*
* do_trace * * do_trace *
*===========================================================================*/ *===========================================================================*/
int do_trace() int
do_trace(void)
{ {
register struct mproc *child; register struct mproc *child;
struct ptrace_range pr; struct ptrace_range pr;
@ -205,7 +206,7 @@ int do_trace()
FALSE /* ksig */); FALSE /* ksig */);
} }
/* Resume the child as if nothing ever happened. */ /* Resume the child as if nothing ever happened. */
child->mp_flags &= ~TRACE_STOPPED; child->mp_flags &= ~TRACE_STOPPED;
child->mp_trace_flags = 0; child->mp_trace_flags = 0;
@ -213,7 +214,7 @@ int do_trace()
break; break;
case T_RESUME: case T_RESUME:
case T_STEP: case T_STEP:
case T_SYSCALL: /* resume execution */ case T_SYSCALL: /* resume execution */
if (m_in.m_lc_pm_ptrace.data < 0 || m_in.m_lc_pm_ptrace.data >= _NSIG) if (m_in.m_lc_pm_ptrace.data < 0 || m_in.m_lc_pm_ptrace.data >= _NSIG)
@ -251,9 +252,8 @@ int do_trace()
/*===========================================================================* /*===========================================================================*
* trace_stop * * trace_stop *
*===========================================================================*/ *===========================================================================*/
void trace_stop(rmp, signo) void
register struct mproc *rmp; trace_stop(register struct mproc *rmp, int signo)
int signo;
{ {
/* A traced process got a signal so stop it. */ /* A traced process got a signal so stop it. */
@ -262,7 +262,7 @@ int signo;
r = sys_trace(T_STOP, rmp->mp_endpoint, 0L, (long *) 0); r = sys_trace(T_STOP, rmp->mp_endpoint, 0L, (long *) 0);
if (r != OK) panic("sys_trace failed: %d", r); if (r != OK) panic("sys_trace failed: %d", r);
rmp->mp_flags |= TRACE_STOPPED; rmp->mp_flags |= TRACE_STOPPED;
if (wait_test(rpmp, rmp)) { if (wait_test(rpmp, rmp)) {
/* TODO: rusage support */ /* TODO: rusage support */

View File

@ -39,7 +39,7 @@ pid_t get_free_pid()
/* Find a free pid for the child and put it in the table. */ /* Find a free pid for the child and put it in the table. */
do { do {
t = 0; t = 0;
next_pid = (next_pid < NR_PIDS ? next_pid + 1 : INIT_PID + 1); next_pid = (next_pid < NR_PIDS ? next_pid + 1 : INIT_PID + 1);
for (rmp = &mproc[0]; rmp < &mproc[NR_PROCS]; rmp++) for (rmp = &mproc[0]; rmp < &mproc[NR_PROCS]; rmp++)
if (rmp->mp_pid == next_pid || rmp->mp_procgrp == next_pid) { if (rmp->mp_pid == next_pid || rmp->mp_procgrp == next_pid) {
@ -53,8 +53,8 @@ pid_t get_free_pid()
/*===========================================================================* /*===========================================================================*
* find_param * * find_param *
*===========================================================================*/ *===========================================================================*/
char *find_param(name) char *
const char *name; find_param(const char *name)
{ {
register const char *namep; register const char *namep;
register char *envp; register char *envp;
@ -62,7 +62,7 @@ const char *name;
for (envp = (char *) monitor_params; *envp != 0;) { for (envp = (char *) monitor_params; *envp != 0;) {
for (namep = name; *namep != 0 && *namep == *envp; namep++, envp++) for (namep = name; *namep != 0 && *namep == *envp; namep++, envp++)
; ;
if (*namep == '\0' && *envp == '=') if (*namep == '\0' && *envp == '=')
return(envp + 1); return(envp + 1);
while (*envp++ != 0) while (*envp++ != 0)
; ;