diff options
author | Julian Elischer <julian@FreeBSD.org> | 1996-08-22 03:50:33 +0000 |
---|---|---|
committer | Julian Elischer <julian@FreeBSD.org> | 1996-08-22 03:50:33 +0000 |
commit | e0d898b48e5734a85b7fc9bb654846bd27a86a03 (patch) | |
tree | 36f241a22c1b649e9fd947dfe20092d354b2dfe0 /sys/kern/kern_fork.c | |
parent | d37f8acb718e36f5e24144bb46ac2ededa7760aa (diff) | |
download | src-e0d898b48e5734a85b7fc9bb654846bd27a86a03.tar.gz src-e0d898b48e5734a85b7fc9bb654846bd27a86a03.zip |
Some cleanups to the callout lists recently added.
note that at_shutdown has a new parameter to indicate When
during a shutdown the callout should be made. also
add a RB_POWEROFF flag to reboot "howto" parameter..
tells the reboot code in our at_shutdown module to turn off the UPS
and kill the power. bound to be useful eventually on laptops
Notes
Notes:
svn path=/head/; revision=17768
Diffstat (limited to 'sys/kern/kern_fork.c')
-rw-r--r-- | sys/kern/kern_fork.c | 67 |
1 files changed, 37 insertions, 30 deletions
diff --git a/sys/kern/kern_fork.c b/sys/kern/kern_fork.c index f6bb2840748b..d037fbd8240f 100644 --- a/sys/kern/kern_fork.c +++ b/sys/kern/kern_fork.c @@ -36,7 +36,7 @@ * SUCH DAMAGE. * * @(#)kern_fork.c 8.6 (Berkeley) 4/8/94 - * $Id: kern_fork.c,v 1.23 1996/07/31 09:26:34 davidg Exp $ + * $Id: kern_fork.c,v 1.24 1996/08/19 02:28:24 julian Exp $ */ #include "opt_ktrace.h" @@ -65,18 +65,19 @@ static int fork1 __P((struct proc *p, int flags, int *retval)); /* - * callout list for things to do at fork time + * These are the stuctures used to create a callout list for things to do + * when forking a process */ typedef struct fork_list_element { struct fork_list_element *next; forklist_fn function; } *fle_p; -static fle_p fork_list; +static fle_p fork_list; #ifndef _SYS_SYSPROTO_H_ struct fork_args { - int dummy; + int dummy; }; #endif @@ -124,8 +125,9 @@ fork1(p1, flags, retval) struct proc *newproc; int count; static int nextpid, pidchecked = 0; - fle_p ep = fork_list; + fle_p ep ; + ep = fork_list; if ((flags & RFPROC) == 0) return (EINVAL); if ((flags & (RFFDG|RFCFDG)) == (RFFDG|RFCFDG)) @@ -346,14 +348,14 @@ again: } /* - * Both processes are set up, - * check if any LKMs want to adjust anything - * What if they have an error? XXX + * Both processes are set up, now check if any LKMs want + * to adjust anything. + * What if they have an error? XXX */ - while(ep) { - (*ep->function)(p1,p2,flags); - ep = ep->next; - } + while (ep) { + (*ep->function)(p1, p2, flags); + ep = ep->next; + } /* * Make child runnable and add to run queue. @@ -385,52 +387,57 @@ again: return (0); } - -/********************************************************* - * general routines to handle adding/deleting items on the - * fork callout list - ***** - * Take the arguments given and put them onto the fork callout list. +/* + * The next two functionms are general routines to handle adding/deleting + * items on the fork callout list. + * + * at_fork(): + * Take the arguments given and put them onto the fork callout list, * However first make sure that it's not already there. - * returns 0 on success. + * Returns 0 on success or a standard error number. */ int at_fork(forklist_fn function) { fle_p ep; - if(rm_at_fork(function)) { + + /* let the programmer know if he's been stupid */ + if (rm_at_fork(function)) printf("fork callout entry already present\n"); - } - ep = malloc(sizeof(*ep),M_TEMP,M_NOWAIT); - if(!ep) return ENOMEM; + ep = malloc(sizeof(*ep), M_TEMP, M_NOWAIT); + if (ep == NULL) + return (ENOMEM); ep->next = fork_list; ep->function = function; fork_list = ep; - return 0; + return (0); } + /* * Scan the exit callout list for the given items and remove them. * Returns the number of items removed. + * Theoretically this value can only be 0 or 1. */ int rm_at_fork(forklist_fn function) { - fle_p *epp,ep; - int count = 0; + fle_p *epp, ep; + int count; + count= 0; epp = &fork_list; ep = *epp; - while(ep) { - if(ep->function == function) { + while (ep) { + if (ep->function == function) { *epp = ep->next; - free(ep,M_TEMP); + free(ep, M_TEMP); count++; } else { epp = &ep->next; } ep = *epp; } - return count; + return (count); } |