SCCS-vsn: sys/kern/init_main.c 8.2
SCCS-vsn: sys/kern/kern_sig.c 8.2
SCCS-vsn: sys/kern/kern_resource.c 8.2
SCCS-vsn: sys/kern/vfs_conf.c 8.2
*
* %sccs.include.redist.c%
*
*
* %sccs.include.redist.c%
*
- * @(#)init_main.c 8.1 (Berkeley) %G%
+ * @(#)init_main.c 8.2 (Berkeley) %G%
*/
#include <sys/param.h>
*/
#include <sys/param.h>
"Copyright (c) 1982, 1986, 1989, 1991, 1993\n\tThe Regents of the University of California. All rights reserved.\n\n";
#endif
"Copyright (c) 1982, 1986, 1989, 1991, 1993\n\tThe Regents of the University of California. All rights reserved.\n\n";
#endif
-/*
- * Components of process 0;
- * never freed.
- */
+/* Components of the first process -- never freed. */
struct session session0;
struct pgrp pgrp0;
struct proc proc0;
struct session session0;
struct pgrp pgrp0;
struct proc proc0;
int cmask = CMASK;
extern struct user *proc0paddr;
int cmask = CMASK;
extern struct user *proc0paddr;
-extern int (*mountroot)();
struct vnode *rootvp, *swapdev_vp;
int boothowto;
struct vnode *rootvp, *swapdev_vp;
int boothowto;
struct timeval runtime;
/*
struct timeval runtime;
/*
- * System startup; initialize the world, create process 0,
- * mount root filesystem, and fork to create init and pagedaemon.
- * Most of the hard work is done in the lower-level initialization
- * routines including startup(), which does memory initialization
- * and autoconfiguration.
+ * System startup; initialize the world, create process 0, mount root
+ * filesystem, and fork to create init and pagedaemon. Most of the
+ * hard work is done in the lower-level initialization routines including
+ * startup(), which does memory initialization and autoconfiguration.
register struct proc *p;
register struct filedesc0 *fdp;
register struct pdevinit *pdev;
register struct proc *p;
register struct filedesc0 *fdp;
register struct pdevinit *pdev;
+ extern int (*mountroot) __P((void));
extern struct pdevinit pdevinit[];
extern void roundrobin __P((void *));
extern void schedcpu __P((void *));
/*
extern struct pdevinit pdevinit[];
extern void roundrobin __P((void *));
extern void schedcpu __P((void *));
/*
- * Initialize curproc before any possible traps/probes
- * to simplify trap processing.
+ * Initialize the current process pointer (curproc) before
+ * any possible traps/probes to simplify trap processing.
*/
p = &proc0;
curproc = p;
*/
p = &proc0;
curproc = p;
kmeminit();
cpu_startup();
kmeminit();
cpu_startup();
- /*
- * set up system process 0 (swapper)
- */
+ /* Create process 0 (the swapper). */
p->p_nice = NZERO;
bcopy("swapper", p->p_comm, sizeof ("swapper"));
p->p_nice = NZERO;
bcopy("swapper", p->p_comm, sizeof ("swapper"));
- /*
- * Setup credentials
- */
+ /* Create credentials. */
cred0.p_refcnt = 1;
p->p_cred = &cred0;
p->p_ucred = crget();
p->p_ucred->cr_ngroups = 1; /* group 0 */
cred0.p_refcnt = 1;
p->p_cred = &cred0;
p->p_ucred = crget();
p->p_ucred->cr_ngroups = 1; /* group 0 */
- /*
- * Create the file descriptor table for process 0.
- */
+ /* Create the file descriptor table. */
fdp = &filedesc0;
p->p_fd = &fdp->fd_fd;
fdp->fd_fd.fd_refcnt = 1;
fdp = &filedesc0;
p->p_fd = &fdp->fd_fd;
fdp->fd_fd.fd_refcnt = 1;
fdp->fd_fd.fd_ofileflags = fdp->fd_dfileflags;
fdp->fd_fd.fd_nfiles = NDFILE;
fdp->fd_fd.fd_ofileflags = fdp->fd_dfileflags;
fdp->fd_fd.fd_nfiles = NDFILE;
- /*
- * Set initial limits
- */
+ /* Create the limits structures. */
p->p_limit = &limit0;
for (i = 0; i < sizeof(p->p_rlimit)/sizeof(p->p_rlimit[0]); i++)
limit0.pl_rlimit[i].rlim_cur =
p->p_limit = &limit0;
for (i = 0; i < sizeof(p->p_rlimit)/sizeof(p->p_rlimit[0]); i++)
limit0.pl_rlimit[i].rlim_cur =
limit0.pl_rlimit[RLIMIT_MEMLOCK].rlim_cur = i / 3;
limit0.p_refcnt = 1;
limit0.pl_rlimit[RLIMIT_MEMLOCK].rlim_cur = i / 3;
limit0.p_refcnt = 1;
- /*
- * Allocate a prototype map so we have something to fork
- */
+ /* Allocate a prototype map so we have something to fork. */
p->p_vmspace = &vmspace0;
vmspace0.vm_refcnt = 1;
pmap_pinit(&vmspace0.vm_pmap);
p->p_vmspace = &vmspace0;
vmspace0.vm_refcnt = 1;
pmap_pinit(&vmspace0.vm_pmap);
p->p_addr = proc0paddr; /* XXX */
/*
p->p_addr = proc0paddr; /* XXX */
/*
- * We continue to place resource usage info
- * and signal actions in the user struct so they're pageable.
+ * We continue to place resource usage info and signal
+ * actions in the user struct so they're pageable.
*/
p->p_stats = &p->p_addr->u_stats;
p->p_sigacts = &p->p_addr->u_sigacts;
*/
p->p_stats = &p->p_addr->u_stats;
p->p_sigacts = &p->p_addr->u_sigacts;
/* Start real time and statistics clocks. */
initclocks();
/* Start real time and statistics clocks. */
initclocks();
- /* Initialize tables. */
+ /* Initialize mbuf's. */
+
+ /* Initialize clists. */
+ clist_init();
+
+ /* Initialize System V style shared memory. */
+ /* Initialize kernel profiling. */
- /* kick off timeout driven events by calling first time */
+ /* Kick off timeout driven events by calling first time. */
roundrobin(NULL);
schedcpu(NULL);
roundrobin(NULL);
schedcpu(NULL);
- /*
- * Set up the root file system and vnode.
- */
+ /* Mount the root file system. */
if ((*mountroot)())
panic("cannot mount root");
if ((*mountroot)())
panic("cannot mount root");
- /*
- * Get vnode for '/'.
- * Setup rootdir and fdp->fd_fd.fd_cdir to point to it.
- */
- if (VFS_ROOT(rootfs, &rootdir))
+
+ /* Get the vnode for '/'. Set fdp->fd_fd.fd_cdir to reference it. */
+ if (VFS_ROOT(rootfs, &rootvnode))
panic("cannot find root vnode");
panic("cannot find root vnode");
- fdp->fd_fd.fd_cdir = rootdir;
+ fdp->fd_fd.fd_cdir = rootvnode;
VREF(fdp->fd_fd.fd_cdir);
VREF(fdp->fd_fd.fd_cdir);
fdp->fd_fd.fd_rdir = NULL;
swapinit();
fdp->fd_fd.fd_rdir = NULL;
swapinit();
p->p_stats->p_start = runtime = mono_time = boottime = time;
p->p_rtime.tv_sec = p->p_rtime.tv_usec = 0;
p->p_stats->p_start = runtime = mono_time = boottime = time;
p->p_rtime.tv_sec = p->p_rtime.tv_usec = 0;
- /*
- * make init process
- */
+ /* Initialize signal state for process 0. */
+
+ /* Create process 1 (init(8)). */
if (fork(p, NULL, rval))
panic("fork init");
if (rval[1]) {
if (fork(p, NULL, rval))
panic("fork init");
if (rval[1]) {
addr != VM_MIN_ADDRESS)
panic("init: couldn't allocate at zero");
addr != VM_MIN_ADDRESS)
panic("init: couldn't allocate at zero");
- /* need just enough stack to exec from */
+ /* Need just enough stack from which to exec. */
addr = trunc_page(USRSTACK - PAGE_SIZE);
if (vm_allocate(&p->p_vmspace->vm_map, &addr,
PAGE_SIZE, FALSE) != KERN_SUCCESS)
addr = trunc_page(USRSTACK - PAGE_SIZE);
if (vm_allocate(&p->p_vmspace->vm_map, &addr,
PAGE_SIZE, FALSE) != KERN_SUCCESS)
return; /* returns to icode */
}
return; /* returns to icode */
}
- /*
- * Start up pageout daemon (process 2).
- */
+ /* Create process 2 (the pageout daemon). */
if (fork(p, NULL, rval))
panic("fork pager");
if (rval[1]) {
if (fork(p, NULL, rval))
panic("fork pager");
if (rval[1]) {
p->p_flag |= SLOAD|SSYS; /* XXX */
bcopy("pagedaemon", curproc->p_comm, sizeof ("pagedaemon"));
vm_pageout();
p->p_flag |= SLOAD|SSYS; /* XXX */
bcopy("pagedaemon", curproc->p_comm, sizeof ("pagedaemon"));
vm_pageout();
- /*
- * enter scheduling loop
- */
- sched();
+ /* The scheduler is an infinite loop. */
+ scheduler();
+ /* NOTREACHED */
*
* %sccs.include.redist.c%
*
*
* %sccs.include.redist.c%
*
- * @(#)kern_resource.c 8.1 (Berkeley) %G%
+ * @(#)kern_resource.c 8.2 (Berkeley) %G%
*/
#include <sys/param.h>
*/
#include <sys/param.h>
if (n < chgp->p_nice && suser(pcred->pc_ucred, &curp->p_acflag))
return (EACCES);
chgp->p_nice = n;
if (n < chgp->p_nice && suser(pcred->pc_ucred, &curp->p_acflag))
return (EACCES);
chgp->p_nice = n;
+ (void)resetpriority(chgp);
*
* %sccs.include.redist.c%
*
*
* %sccs.include.redist.c%
*
- * @(#)kern_sig.c 8.1 (Berkeley) %G%
+ * @(#)kern_sig.c 8.2 (Berkeley) %G%
*/
#define SIGPROP /* include signal properties table */
*/
#define SIGPROP /* include signal properties table */
#include <sys/wait.h>
#include <sys/ktrace.h>
#include <sys/syslog.h>
#include <sys/wait.h>
#include <sys/ktrace.h>
#include <sys/syslog.h>
#include <sys/user.h> /* for coredump */
/*
#include <sys/user.h> /* for coredump */
/*
- * Can process p, with pcred pc, send the signal signo to process q?
+ * Can process p, with pcred pc, send the signal signum to process q?
-#define CANSIGNAL(p, pc, q, signo) \
+#define CANSIGNAL(p, pc, q, signum) \
((pc)->pc_ucred->cr_uid == 0 || \
(pc)->p_ruid == (q)->p_cred->p_ruid || \
(pc)->pc_ucred->cr_uid == (q)->p_cred->p_ruid || \
(pc)->p_ruid == (q)->p_ucred->cr_uid || \
(pc)->pc_ucred->cr_uid == (q)->p_ucred->cr_uid || \
((pc)->pc_ucred->cr_uid == 0 || \
(pc)->p_ruid == (q)->p_cred->p_ruid || \
(pc)->pc_ucred->cr_uid == (q)->p_cred->p_ruid || \
(pc)->p_ruid == (q)->p_ucred->cr_uid || \
(pc)->pc_ucred->cr_uid == (q)->p_ucred->cr_uid || \
- ((signo) == SIGCONT && (q)->p_session == (p)->p_session))
+ ((signum) == SIGCONT && (q)->p_session == (p)->p_session))
struct sigaction *nsa;
struct sigaction *osa;
};
struct sigaction *nsa;
struct sigaction *osa;
};
struct sigaction vec;
register struct sigaction *sa;
register struct sigacts *ps = p->p_sigacts;
struct sigaction vec;
register struct sigaction *sa;
register struct sigacts *ps = p->p_sigacts;
- sig = uap->signo;
- if (sig <= 0 || sig >= NSIG || sig == SIGKILL || sig == SIGSTOP)
+ signum = uap->signum;
+ if (signum <= 0 || signum >= NSIG ||
+ signum == SIGKILL || signum == SIGSTOP)
return (EINVAL);
sa = &vec;
if (uap->osa) {
return (EINVAL);
sa = &vec;
if (uap->osa) {
- sa->sa_handler = ps->ps_sigact[sig];
- sa->sa_mask = ps->ps_catchmask[sig];
- bit = sigmask(sig);
+ sa->sa_handler = ps->ps_sigact[signum];
+ sa->sa_mask = ps->ps_catchmask[signum];
+ bit = sigmask(signum);
sa->sa_flags = 0;
if ((ps->ps_sigonstack & bit) != 0)
sa->sa_flags |= SA_ONSTACK;
sa->sa_flags = 0;
if ((ps->ps_sigonstack & bit) != 0)
sa->sa_flags |= SA_ONSTACK;
if (error = copyin((caddr_t)uap->nsa, (caddr_t)sa,
sizeof (vec)))
return (error);
if (error = copyin((caddr_t)uap->nsa, (caddr_t)sa,
sizeof (vec)))
return (error);
+ setsigvec(p, signum, sa);
+setsigvec(p, signum, sa)
register struct sigaction *sa;
{
register struct sigacts *ps = p->p_sigacts;
register int bit;
register struct sigaction *sa;
{
register struct sigacts *ps = p->p_sigacts;
register int bit;
/*
* Change setting atomically.
*/
(void) splhigh();
/*
* Change setting atomically.
*/
(void) splhigh();
- ps->ps_sigact[sig] = sa->sa_handler;
- ps->ps_catchmask[sig] = sa->sa_mask &~ sigcantmask;
+ ps->ps_sigact[signum] = sa->sa_handler;
+ ps->ps_catchmask[signum] = sa->sa_mask &~ sigcantmask;
if ((sa->sa_flags & SA_RESTART) == 0)
ps->ps_sigintr |= bit;
else
if ((sa->sa_flags & SA_RESTART) == 0)
ps->ps_sigintr |= bit;
else
else
ps->ps_usertramp &= ~bit;
#endif
else
ps->ps_usertramp &= ~bit;
#endif
+ if (signum == SIGCHLD) {
if (sa->sa_flags & SA_NOCLDSTOP)
p->p_flag |= SNOCLDSTOP;
else
if (sa->sa_flags & SA_NOCLDSTOP)
p->p_flag |= SNOCLDSTOP;
else
* as we have to restart the process.
*/
if (sa->sa_handler == SIG_IGN ||
* as we have to restart the process.
*/
if (sa->sa_handler == SIG_IGN ||
- (sigprop[sig] & SA_IGNORE && sa->sa_handler == SIG_DFL)) {
+ (sigprop[signum] & SA_IGNORE && sa->sa_handler == SIG_DFL)) {
p->p_sig &= ~bit; /* never to be seen again */
p->p_sig &= ~bit; /* never to be seen again */
p->p_sigignore |= bit; /* easier in psignal */
p->p_sigcatch &= ~bit;
} else {
p->p_sigignore |= bit; /* easier in psignal */
p->p_sigcatch &= ~bit;
} else {
* Generalized interface signal handler, 4.3-compatible.
*/
struct osigvec_args {
* Generalized interface signal handler, 4.3-compatible.
*/
struct osigvec_args {
struct sigvec *nsv;
struct sigvec *osv;
};
struct sigvec *nsv;
struct sigvec *osv;
};
struct sigvec vec;
register struct sigacts *ps = p->p_sigacts;
register struct sigvec *sv;
struct sigvec vec;
register struct sigacts *ps = p->p_sigacts;
register struct sigvec *sv;
- sig = uap->signo;
- if (sig <= 0 || sig >= NSIG || sig == SIGKILL || sig == SIGSTOP)
+ signum = uap->signum;
+ if (signum <= 0 || signum >= NSIG ||
+ signum == SIGKILL || signum == SIGSTOP)
return (EINVAL);
sv = &vec;
if (uap->osv) {
return (EINVAL);
sv = &vec;
if (uap->osv) {
- *(sig_t *)&sv->sv_handler = ps->ps_sigact[sig];
- sv->sv_mask = ps->ps_catchmask[sig];
- bit = sigmask(sig);
+ *(sig_t *)&sv->sv_handler = ps->ps_sigact[signum];
+ sv->sv_mask = ps->ps_catchmask[signum];
+ bit = sigmask(signum);
sv->sv_flags = 0;
if ((ps->ps_sigonstack & bit) != 0)
sv->sv_flags |= SV_ONSTACK;
sv->sv_flags = 0;
if ((ps->ps_sigonstack & bit) != 0)
sv->sv_flags |= SV_ONSTACK;
sv->sv_flags |= SA_USERTRAMP;
#endif
sv->sv_flags ^= SA_RESTART; /* opposite of SV_INTERRUPT */
sv->sv_flags |= SA_USERTRAMP;
#endif
sv->sv_flags ^= SA_RESTART; /* opposite of SV_INTERRUPT */
- setsigvec(p, sig, (struct sigaction *)sv);
+ setsigvec(p, signum, (struct sigaction *)sv);
struct kill_args {
int pid;
struct kill_args {
int pid;
};
/* ARGSUSED */
kill(cp, uap, retval)
};
/* ARGSUSED */
kill(cp, uap, retval)
register struct proc *p;
register struct pcred *pc = cp->p_cred;
register struct proc *p;
register struct pcred *pc = cp->p_cred;
- if ((unsigned) uap->signo >= NSIG)
+ if ((u_int)uap->signum >= NSIG)
return (EINVAL);
if (uap->pid > 0) {
/* kill single process */
return (EINVAL);
if (uap->pid > 0) {
/* kill single process */
- p = pfind(uap->pid);
- if (p == 0)
+ if ((p = pfind(uap->pid)) == NULL)
- if (!CANSIGNAL(cp, pc, p, uap->signo))
+ if (!CANSIGNAL(cp, pc, p, uap->signum))
- if (uap->signo)
- psignal(p, uap->signo);
+ if (uap->signum)
+ psignal(p, uap->signum);
return (0);
}
switch (uap->pid) {
case -1: /* broadcast signal */
return (0);
}
switch (uap->pid) {
case -1: /* broadcast signal */
- return (killpg1(cp, uap->signo, 0, 1));
+ return (killpg1(cp, uap->signum, 0, 1));
case 0: /* signal own process group */
case 0: /* signal own process group */
- return (killpg1(cp, uap->signo, 0, 0));
+ return (killpg1(cp, uap->signum, 0, 0));
default: /* negative explicit process group */
default: /* negative explicit process group */
- return (killpg1(cp, uap->signo, -uap->pid, 0));
+ return (killpg1(cp, uap->signum, -uap->pid, 0));
#if defined(COMPAT_43) || defined(COMPAT_SUNOS)
struct okillpg_args {
int pgid;
#if defined(COMPAT_43) || defined(COMPAT_SUNOS)
struct okillpg_args {
int pgid;
};
/* ARGSUSED */
okillpg(p, uap, retval)
};
/* ARGSUSED */
okillpg(p, uap, retval)
- if ((unsigned) uap->signo >= NSIG)
+ if ((u_int)uap->signum >= NSIG)
- return (killpg1(p, uap->signo, uap->pgid, 0));
+ return (killpg1(p, uap->signum, uap->pgid, 0));
}
#endif /* COMPAT_43 || COMPAT_SUNOS */
}
#endif /* COMPAT_43 || COMPAT_SUNOS */
* Common code for kill process group/broadcast kill.
* cp is calling process.
*/
* Common code for kill process group/broadcast kill.
* cp is calling process.
*/
-killpg1(cp, signo, pgid, all)
+killpg1(cp, signum, pgid, all)
register struct proc *cp;
register struct proc *cp;
{
register struct proc *p;
register struct pcred *pc = cp->p_cred;
{
register struct proc *p;
register struct pcred *pc = cp->p_cred;
*/
for (p = (struct proc *)allproc; p != NULL; p = p->p_nxt) {
if (p->p_pid <= 1 || p->p_flag & SSYS ||
*/
for (p = (struct proc *)allproc; p != NULL; p = p->p_nxt) {
if (p->p_pid <= 1 || p->p_flag & SSYS ||
- p == cp || !CANSIGNAL(cp, pc, p, signo))
+ p == cp || !CANSIGNAL(cp, pc, p, signum))
- if (signo)
- psignal(p, signo);
+ if (signum)
+ psignal(p, signum);
}
for (p = pgrp->pg_mem; p != NULL; p = p->p_pgrpnxt) {
if (p->p_pid <= 1 || p->p_flag & SSYS ||
}
for (p = pgrp->pg_mem; p != NULL; p = p->p_pgrpnxt) {
if (p->p_pid <= 1 || p->p_flag & SSYS ||
- p->p_stat == SZOMB || !CANSIGNAL(cp, pc, p, signo))
+ p->p_stat == SZOMB ||
+ !CANSIGNAL(cp, pc, p, signum))
- if (signo)
- psignal(p, signo);
+ if (signum)
+ psignal(p, signum);
}
}
return (nfound ? 0 : ESRCH);
}
/*
}
}
return (nfound ? 0 : ESRCH);
}
/*
- * Send the specified signal to
- * all processes with 'pgid' as
- * process group.
+ * Send a signal to a process group.
-gsignal(pgid, sig)
- int pgid, sig;
+gsignal(pgid, signum)
+ int pgid, signum;
{
struct pgrp *pgrp;
if (pgid && (pgrp = pgfind(pgid)))
{
struct pgrp *pgrp;
if (pgid && (pgrp = pgfind(pgid)))
- pgsignal(pgrp, sig, 0);
+ pgsignal(pgrp, signum, 0);
- * Send sig to every member of a process group.
- * If checktty is 1, limit to members which have a controlling
- * terminal.
+ * Send a signal to a process group. If checktty is 1,
+ * limit to members which have a controlling terminal.
-pgsignal(pgrp, sig, checkctty)
+pgsignal(pgrp, signum, checkctty)
{
register struct proc *p;
if (pgrp)
for (p = pgrp->pg_mem; p != NULL; p = p->p_pgrpnxt)
if (checkctty == 0 || p->p_flag & SCTTY)
{
register struct proc *p;
if (pgrp)
for (p = pgrp->pg_mem; p != NULL; p = p->p_pgrpnxt)
if (checkctty == 0 || p->p_flag & SCTTY)
* Otherwise, post it normally.
*/
void
* Otherwise, post it normally.
*/
void
-trapsignal(p, sig, code)
+trapsignal(p, signum, code)
- register int sig;
- unsigned code;
+ register int signum;
+ u_int code;
{
register struct sigacts *ps = p->p_sigacts;
int mask;
{
register struct sigacts *ps = p->p_sigacts;
int mask;
+ mask = sigmask(signum);
if ((p->p_flag & STRC) == 0 && (p->p_sigcatch & mask) != 0 &&
(p->p_sigmask & mask) == 0) {
p->p_stats->p_ru.ru_nsignals++;
#ifdef KTRACE
if (KTRPOINT(p, KTR_PSIG))
if ((p->p_flag & STRC) == 0 && (p->p_sigcatch & mask) != 0 &&
(p->p_sigmask & mask) == 0) {
p->p_stats->p_ru.ru_nsignals++;
#ifdef KTRACE
if (KTRPOINT(p, KTR_PSIG))
- ktrpsig(p->p_tracep, sig, ps->ps_sigact[sig],
+ ktrpsig(p->p_tracep, signum, ps->ps_sigact[signum],
p->p_sigmask, code);
#endif
p->p_sigmask, code);
#endif
- sendsig(ps->ps_sigact[sig], sig, p->p_sigmask, code);
- p->p_sigmask |= ps->ps_catchmask[sig] | mask;
+ sendsig(ps->ps_sigact[signum], signum, p->p_sigmask, code);
+ p->p_sigmask |= ps->ps_catchmask[signum] | mask;
} else {
ps->ps_code = code; /* XXX for core dump/debugger */
} else {
ps->ps_code = code; /* XXX for core dump/debugger */
- * Send the specified signal to the specified process.
- * If the signal has an action, the action is usually performed
- * by the target process rather than the caller; we simply add
+ * Send the signal to the process. If the signal has an action, the action
+ * is usually performed by the target process rather than the caller; we add
* the signal to the set of pending signals for the process.
* the signal to the set of pending signals for the process.
- * o When a stop signal is sent to a sleeping process that takes the default
- * action, the process is stopped without awakening it.
+ * o When a stop signal is sent to a sleeping process that takes the
+ * default action, the process is stopped without awakening it.
* o SIGCONT restarts stopped processes (or puts them back to sleep)
* regardless of the signal action (eg, blocked or ignored).
* o SIGCONT restarts stopped processes (or puts them back to sleep)
* regardless of the signal action (eg, blocked or ignored).
* Other ignored signals are discarded immediately.
*/
void
* Other ignored signals are discarded immediately.
*/
void
{
register int s, prop;
register sig_t action;
int mask;
{
register int s, prop;
register sig_t action;
int mask;
- if ((unsigned)sig >= NSIG || sig == 0)
- panic("psignal sig");
- mask = sigmask(sig);
- prop = sigprop[sig];
+ if ((u_int)signum >= NSIG || signum == 0)
+ panic("psignal signal number");
+ mask = sigmask(signum);
+ prop = sigprop[signum];
/*
* If proc is traced, always give parent a chance.
/*
* If proc is traced, always give parent a chance.
if (p->p_flag & SPPWAIT)
goto out;
p->p_sig &= ~mask;
if (p->p_flag & SPPWAIT)
goto out;
p->p_sig &= ~mask;
if ((p->p_pptr->p_flag & SNOCLDSTOP) == 0)
psignal(p->p_pptr, SIGCHLD);
stop(p);
if ((p->p_pptr->p_flag & SNOCLDSTOP) == 0)
psignal(p->p_pptr, SIGCHLD);
stop(p);
/*
* Kill signal always sets processes running.
*/
/*
* Kill signal always sets processes running.
*/
goto runfast;
if (prop & SA_CONT) {
goto runfast;
if (prop & SA_CONT) {
- * If the current process has a signal to process (should be caught
- * or cause termination, should interrupt current syscall),
- * return the signal number. Stop signals with default action
- * are processed immediately, then cleared; they aren't returned.
- * This is checked after each entry to the system for a syscall
- * or trap (though this can usually be done without actually calling
- * issig by checking the pending signal masks in the CURSIG macro.)
- * The normal call sequence is
+ * If the current process has received a signal (should be caught or cause
+ * termination, should interrupt current syscall), return the signal number.
+ * Stop signals with default action are processed immediately, then cleared;
+ * they aren't returned. This is checked after each entry to the system for
+ * a syscall or trap (though this can usually be done without calling issig
+ * by checking the pending signal masks in the CURSIG macro.) The normal call
+ * sequence is
- * while (sig = CURSIG(curproc))
- * psig(sig);
+ * while (signum = CURSIG(curproc))
+ * psig(signum);
*/
issig(p)
register struct proc *p;
{
*/
issig(p)
register struct proc *p;
{
- register int sig, mask, prop;
+ register int signum, mask, prop;
for (;;) {
mask = p->p_sig &~ p->p_sigmask;
for (;;) {
mask = p->p_sig &~ p->p_sigmask;
mask &= ~stopsigmask;
if (mask == 0) /* no signal to send */
return (0);
mask &= ~stopsigmask;
if (mask == 0) /* no signal to send */
return (0);
- sig = ffs((long)mask);
- mask = sigmask(sig);
- prop = sigprop[sig];
+ signum = ffs((long)mask);
+ mask = sigmask(signum);
+ prop = sigprop[signum];
/*
* We should see pending but ignored signals
* only if STRC was on when they were posted.
/*
* We should see pending but ignored signals
* only if STRC was on when they were posted.
* If traced, always stop, and stay
* stopped until released by the parent.
*/
* If traced, always stop, and stay
* stopped until released by the parent.
*/
psignal(p->p_pptr, SIGCHLD);
do {
stop(p);
psignal(p->p_pptr, SIGCHLD);
do {
stop(p);
* otherwise we just look for signals again.
*/
p->p_sig &= ~mask; /* clear the old signal */
* otherwise we just look for signals again.
*/
p->p_sig &= ~mask; /* clear the old signal */
- sig = p->p_xstat;
- if (sig == 0)
+ signum = p->p_xstat;
+ if (signum == 0)
* If signal is being masked,
* look for other signals.
*/
* If signal is being masked,
* look for other signals.
*/
+ mask = sigmask(signum);
p->p_sig |= mask;
if (p->p_sigmask & mask)
continue;
p->p_sig |= mask;
if (p->p_sigmask & mask)
continue;
* Return the signal's number, or fall through
* to clear it from the pending mask.
*/
* Return the signal's number, or fall through
* to clear it from the pending mask.
*/
- switch ((int)p->p_sigacts->ps_sigact[sig]) {
+ switch ((int)p->p_sigacts->ps_sigact[signum]) {
* in init? XXX
*/
printf("Process (pid %d) got signal %d\n",
* in init? XXX
*/
printf("Process (pid %d) got signal %d\n",
#endif
break; /* == ignore */
}
#endif
break; /* == ignore */
}
(p->p_pgrp->pg_jobc == 0 &&
prop & SA_TTYSTOP))
break; /* == ignore */
(p->p_pgrp->pg_jobc == 0 &&
prop & SA_TTYSTOP))
break; /* == ignore */
stop(p);
if ((p->p_pptr->p_flag & SNOCLDSTOP) == 0)
psignal(p->p_pptr, SIGCHLD);
stop(p);
if ((p->p_pptr->p_flag & SNOCLDSTOP) == 0)
psignal(p->p_pptr, SIGCHLD);
*/
break; /* == ignore */
} else
*/
break; /* == ignore */
} else
/*NOTREACHED*/
case SIG_IGN:
/*NOTREACHED*/
case SIG_IGN:
* This signal has an action, let
* psig process it.
*/
* This signal has an action, let
* psig process it.
*/
}
p->p_sig &= ~mask; /* take the signal! */
}
}
p->p_sig &= ~mask; /* take the signal! */
}
- * Put the argument process into the stopped
- * state and notify the parent via wakeup.
- * Signals are handled elsewhere.
- * The process must not be on the run queue.
+ * Put the argument process into the stopped state and notify the parent
+ * via wakeup. Signals are handled elsewhere. The process must not be
+ * on the run queue.
*/
stop(p)
register struct proc *p;
*/
stop(p)
register struct proc *p;
* from the current set of pending signals.
*/
void
* from the current set of pending signals.
*/
void
-psig(sig)
- register int sig;
+psig(signum)
+ register int signum;
{
register struct proc *p = curproc;
register struct sigacts *ps = p->p_sigacts;
{
register struct proc *p = curproc;
register struct sigacts *ps = p->p_sigacts;
int mask, returnmask;
#ifdef DIAGNOSTIC
int mask, returnmask;
#ifdef DIAGNOSTIC
+ mask = sigmask(signum);
- action = ps->ps_sigact[sig];
+ action = ps->ps_sigact[signum];
#ifdef KTRACE
if (KTRPOINT(p, KTR_PSIG))
#ifdef KTRACE
if (KTRPOINT(p, KTR_PSIG))
- ktrpsig(p->p_tracep, sig, action, ps->ps_flags & SAS_OLDMASK ?
+ ktrpsig(p->p_tracep,
+ signum, action, ps->ps_flags & SAS_OLDMASK ?
ps->ps_oldmask : p->p_sigmask, 0);
#endif
if (action == SIG_DFL) {
ps->ps_oldmask : p->p_sigmask, 0);
#endif
if (action == SIG_DFL) {
* Default action, where the default is to kill
* the process. (Other cases were ignored above.)
*/
* Default action, where the default is to kill
* the process. (Other cases were ignored above.)
*/
/* NOTREACHED */
} else {
/*
/* NOTREACHED */
} else {
/*
ps->ps_flags &= ~SAS_OLDMASK;
} else
returnmask = p->p_sigmask;
ps->ps_flags &= ~SAS_OLDMASK;
} else
returnmask = p->p_sigmask;
- p->p_sigmask |= ps->ps_catchmask[sig] | mask;
+ p->p_sigmask |= ps->ps_catchmask[signum] | mask;
(void) spl0();
p->p_stats->p_ru.ru_nsignals++;
(void) spl0();
p->p_stats->p_ru.ru_nsignals++;
- sendsig(action, sig, returnmask, 0);
+ sendsig(action, signum, returnmask, 0);
- * Force the current process to exit with the specified
- * signal, dumping core if appropriate. We bypass the normal
- * tests for masked and caught signals, allowing unrecoverable
- * failures to terminate the process without changing signal state.
- * Mark the accounting record with the signal termination.
- * If dumping core, save the signal number for the debugger.
- * Calls exit and does not return.
+ * Force the current process to exit with the specified signal, dumping core
+ * if appropriate. We bypass the normal tests for masked and caught signals,
+ * allowing unrecoverable failures to terminate the process without changing
+ * signal state. Mark the accounting record with the signal termination.
+ * If dumping core, save the signal number for the debugger. Calls exit and
+ * does not return.
- if (sigprop[sig] & SA_CORE) {
- p->p_sigacts->ps_sig = sig;
+ if (sigprop[signum] & SA_CORE) {
+ p->p_sigacts->ps_sig = signum;
- exit1(p, W_EXITCODE(0, sig));
+ exit1(p, W_EXITCODE(0, signum));
- * Create a core dump.
- * The file name is "core.progname".
- * Core dumps are not created if the process is setuid.
+ * Dump core, into a file named "core.progname".
+ * Do not drop core if the process was setuid/setgid.
*/
coredump(p)
register struct proc *p;
*/
coredump(p)
register struct proc *p;
struct vattr vattr;
int error, error1;
struct nameidata nd;
struct vattr vattr;
int error, error1;
struct nameidata nd;
- char name[MAXCOMLEN+6]; /* core.progname */
+ char name[MAXCOMLEN+6]; /* progname.core */
- if (pcred->p_svuid != pcred->p_ruid ||
- pcred->p_svgid != pcred->p_rgid)
+ if (pcred->p_svuid != pcred->p_ruid || pcred->p_svgid != pcred->p_rgid)
return (EFAULT);
if (ctob(UPAGES + vm->vm_dsize + vm->vm_ssize) >=
p->p_rlimit[RLIMIT_CORE].rlim_cur)
return (EFAULT);
return (EFAULT);
if (ctob(UPAGES + vm->vm_dsize + vm->vm_ssize) >=
p->p_rlimit[RLIMIT_CORE].rlim_cur)
return (EFAULT);
- sprintf(name, "core.%s", p->p_comm);
+ sprintf(name, "%s.core", p->p_comm);
NDINIT(&nd, LOOKUP, FOLLOW, UIO_SYSSPACE, name, p);
NDINIT(&nd, LOOKUP, FOLLOW, UIO_SYSSPACE, name, p);
- if (error = vn_open(&nd, O_CREAT|FWRITE, 0644))
+ if (error = vn_open(&nd,
+ O_CREAT | FWRITE, S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH))
return (error);
vp = nd.ni_vp;
return (error);
vp = nd.ni_vp;
- if (vp->v_type != VREG || VOP_GETATTR(vp, &vattr, cred, p) ||
- vattr.va_nlink != 1) {
+
+ /* Don't dump to non-regular files or files with links. */
+ if (vp->v_type != VREG ||
+ VOP_GETATTR(vp, &vattr, cred, p) || vattr.va_nlink != 1) {
error = EFAULT;
goto out;
}
error = EFAULT;
goto out;
}
*
* %sccs.include.redist.c%
*
*
* %sccs.include.redist.c%
*
- * @(#)vfs_conf.c 8.1 (Berkeley) %G%
+ * @(#)vfs_conf.c 8.2 (Berkeley) %G%
*/
#include <sys/param.h>
*/
#include <sys/param.h>
* These define the root filesystem and device.
*/
struct mount *rootfs;
* These define the root filesystem and device.
*/
struct mount *rootfs;
+struct vnode *rootvnode;
/*
* Set up the filesystem operations for vnodes.
/*
* Set up the filesystem operations for vnodes.