diff options
author | jhb <jhb@FreeBSD.org> | 2010-07-08 19:15:26 +0000 |
---|---|---|
committer | jhb <jhb@FreeBSD.org> | 2010-07-08 19:15:26 +0000 |
commit | 1f4cf66ed286294c1578f5a247efe6d564a26ad2 (patch) | |
tree | 97e607c679dcf032deddf8121c3f12843f31ac91 /sys | |
parent | 05f75c27c0fca985991728f69a41e390bc78ae10 (diff) | |
download | FreeBSD-src-1f4cf66ed286294c1578f5a247efe6d564a26ad2.zip FreeBSD-src-1f4cf66ed286294c1578f5a247efe6d564a26ad2.tar.gz |
- Various style and whitespace fixes.
- Make sugid_coredump and kern_logsigexit private to kern_sig.c.
Submitted by: bde (partially)
MFC after: 1 month
Diffstat (limited to 'sys')
-rw-r--r-- | sys/kern/kern_sig.c | 4 | ||||
-rw-r--r-- | sys/sys/signalvar.h | 138 |
2 files changed, 66 insertions, 76 deletions
diff --git a/sys/kern/kern_sig.c b/sys/kern/kern_sig.c index af3c7da..a6c56d0 100644 --- a/sys/kern/kern_sig.c +++ b/sys/kern/kern_sig.c @@ -125,7 +125,7 @@ struct filterops sig_filtops = { .f_event = filt_signal, }; -int kern_logsigexit = 1; +static int kern_logsigexit = 1; SYSCTL_INT(_kern, KERN_LOGSIGEXIT, logsigexit, CTLFLAG_RW, &kern_logsigexit, 0, "Log processes quitting on abnormal signals to syslog(3)"); @@ -167,7 +167,7 @@ SYSINIT(signal, SI_SUB_P1003_1B, SI_ORDER_FIRST+3, sigqueue_start, NULL); (cr1)->cr_ruid == (cr2)->cr_uid || \ (cr1)->cr_uid == (cr2)->cr_uid) -int sugid_coredump; +static int sugid_coredump; SYSCTL_INT(_kern, OID_AUTO, sugid_coredump, CTLFLAG_RW, &sugid_coredump, 0, "Allow setuid and setgid processes to dump core"); diff --git a/sys/sys/signalvar.h b/sys/sys/signalvar.h index 392402e..bd6d9da 100644 --- a/sys/sys/signalvar.h +++ b/sys/sys/signalvar.h @@ -39,8 +39,7 @@ #include <sys/signal.h> /* - * Kernel signal definitions and data structures, - * not exported to user programs. + * Kernel signal definitions and data structures. */ /* @@ -60,7 +59,7 @@ struct sigacts { sigset_t ps_siginfo; /* Signals that want SA_SIGINFO args. */ sigset_t ps_sigignore; /* Signals being ignored. */ sigset_t ps_sigcatch; /* Signals being caught by user. */ - sigset_t ps_freebsd4; /* signals using freebsd4 ucontext. */ + sigset_t ps_freebsd4; /* Signals using freebsd4 ucontext. */ sigset_t ps_osigset; /* Signals using <= 3.x osigset_t. */ sigset_t ps_usertramp; /* SunOS compat; libc sigtramp. XXX */ int ps_flag; @@ -72,10 +71,9 @@ struct sigacts { #define PS_NOCLDSTOP 0x0002 /* No SIGCHLD when children stop. */ #define PS_CLDSIGIGN 0x0004 /* The SIGCHLD handler is SIG_IGN. */ -#if defined(_KERNEL) && defined(COMPAT_43) -/* - * Compatibility. - */ +#ifdef _KERNEL + +#ifdef COMPAT_43 typedef struct { struct osigcontext si_sc; int si_signo; @@ -93,7 +91,7 @@ struct osigaction { }; typedef void __osiginfohandler_t(int, osiginfo_t *, void *); -#endif /* _KERNEL && COMPAT_43 */ +#endif /* COMPAT_43 */ /* additional signal action values, used only temporarily/internally */ #define SIG_CATCH ((__sighandler_t *)2) @@ -102,78 +100,80 @@ typedef void __osiginfohandler_t(int, osiginfo_t *, void *); /* * get signal action for process and signal; currently only for current process */ -#define SIGACTION(p, sig) (p->p_sigacts->ps_sigact[_SIG_IDX(sig)]) +#define SIGACTION(p, sig) (p->p_sigacts->ps_sigact[_SIG_IDX(sig)]) + +#endif /* _KERNEL */ /* - * sigset_t manipulation macros + * sigset_t manipulation macros. */ -#define SIGADDSET(set, signo) \ +#define SIGADDSET(set, signo) \ ((set).__bits[_SIG_WORD(signo)] |= _SIG_BIT(signo)) -#define SIGDELSET(set, signo) \ +#define SIGDELSET(set, signo) \ ((set).__bits[_SIG_WORD(signo)] &= ~_SIG_BIT(signo)) -#define SIGEMPTYSET(set) \ +#define SIGEMPTYSET(set) \ do { \ int __i; \ for (__i = 0; __i < _SIG_WORDS; __i++) \ (set).__bits[__i] = 0; \ } while (0) -#define SIGFILLSET(set) \ +#define SIGFILLSET(set) \ do { \ int __i; \ for (__i = 0; __i < _SIG_WORDS; __i++) \ (set).__bits[__i] = ~0U; \ } while (0) -#define SIGISMEMBER(set, signo) \ +#define SIGISMEMBER(set, signo) \ ((set).__bits[_SIG_WORD(signo)] & _SIG_BIT(signo)) -#define SIGISEMPTY(set) (__sigisempty(&(set))) -#define SIGNOTEMPTY(set) (!__sigisempty(&(set))) +#define SIGISEMPTY(set) (__sigisempty(&(set))) +#define SIGNOTEMPTY(set) (!__sigisempty(&(set))) -#define SIGSETEQ(set1, set2) (__sigseteq(&(set1), &(set2))) -#define SIGSETNEQ(set1, set2) (!__sigseteq(&(set1), &(set2))) +#define SIGSETEQ(set1, set2) (__sigseteq(&(set1), &(set2))) +#define SIGSETNEQ(set1, set2) (!__sigseteq(&(set1), &(set2))) -#define SIGSETOR(set1, set2) \ +#define SIGSETOR(set1, set2) \ do { \ int __i; \ for (__i = 0; __i < _SIG_WORDS; __i++) \ (set1).__bits[__i] |= (set2).__bits[__i]; \ } while (0) -#define SIGSETAND(set1, set2) \ +#define SIGSETAND(set1, set2) \ do { \ int __i; \ for (__i = 0; __i < _SIG_WORDS; __i++) \ (set1).__bits[__i] &= (set2).__bits[__i]; \ } while (0) -#define SIGSETNAND(set1, set2) \ +#define SIGSETNAND(set1, set2) \ do { \ int __i; \ for (__i = 0; __i < _SIG_WORDS; __i++) \ (set1).__bits[__i] &= ~(set2).__bits[__i]; \ } while (0) -#define SIGSETLO(set1, set2) ((set1).__bits[0] = (set2).__bits[0]) -#define SIGSETOLD(set, oset) ((set).__bits[0] = (oset)) +#define SIGSETLO(set1, set2) ((set1).__bits[0] = (set2).__bits[0]) +#define SIGSETOLD(set, oset) ((set).__bits[0] = (oset)) -#define SIG_CANTMASK(set) \ +#define SIG_CANTMASK(set) \ SIGDELSET(set, SIGKILL), SIGDELSET(set, SIGSTOP) -#define SIG_STOPSIGMASK(set) \ +#define SIG_STOPSIGMASK(set) \ SIGDELSET(set, SIGSTOP), SIGDELSET(set, SIGTSTP), \ SIGDELSET(set, SIGTTIN), SIGDELSET(set, SIGTTOU) -#define SIG_CONTSIGMASK(set) \ +#define SIG_CONTSIGMASK(set) \ SIGDELSET(set, SIGCONT) -#define sigcantmask (sigmask(SIGKILL) | sigmask(SIGSTOP)) +#define sigcantmask (sigmask(SIGKILL) | sigmask(SIGSTOP)) -#define SIG2OSIG(sig, osig) (osig = (sig).__bits[0]) -#define OSIG2SIG(osig, sig) SIGEMPTYSET(sig); (sig).__bits[0] = osig +#define SIG2OSIG(sig, osig) (osig = (sig).__bits[0]) +#define OSIG2SIG(osig, sig) SIGEMPTYSET(sig); (sig).__bits[0] = osig static __inline int __sigisempty(sigset_t *set) @@ -215,24 +215,24 @@ typedef struct ksiginfo { struct sigqueue *ksi_sigq; } ksiginfo_t; -#define ksi_signo ksi_info.si_signo -#define ksi_errno ksi_info.si_errno -#define ksi_code ksi_info.si_code -#define ksi_pid ksi_info.si_pid -#define ksi_uid ksi_info.si_uid -#define ksi_status ksi_info.si_status -#define ksi_addr ksi_info.si_addr -#define ksi_value ksi_info.si_value -#define ksi_band ksi_info.si_band -#define ksi_trapno ksi_info.si_trapno -#define ksi_overrun ksi_info.si_overrun -#define ksi_timerid ksi_info.si_timerid -#define ksi_mqd ksi_info.si_mqd +#define ksi_signo ksi_info.si_signo +#define ksi_errno ksi_info.si_errno +#define ksi_code ksi_info.si_code +#define ksi_pid ksi_info.si_pid +#define ksi_uid ksi_info.si_uid +#define ksi_status ksi_info.si_status +#define ksi_addr ksi_info.si_addr +#define ksi_value ksi_info.si_value +#define ksi_band ksi_info.si_band +#define ksi_trapno ksi_info.si_trapno +#define ksi_overrun ksi_info.si_overrun +#define ksi_timerid ksi_info.si_timerid +#define ksi_mqd ksi_info.si_mqd /* bits for ksi_flags */ -#define KSI_TRAP 0x01 /* Generated by trap. */ +#define KSI_TRAP 0x01 /* Generated by trap. */ #define KSI_EXT 0x02 /* Externally managed ksi. */ -#define KSI_INS 0x04 /* Directly insert ksi, not the copy */ +#define KSI_INS 0x04 /* Directly insert ksi, not the copy */ #define KSI_SIGQ 0x08 /* Generated by sigqueue, might ret EGAIN. */ #define KSI_HEAD 0x10 /* Insert into head, not tail. */ #define KSI_COPYMASK (KSI_TRAP|KSI_SIGQ) @@ -275,12 +275,12 @@ sigsetmasked(sigset_t *set, sigset_t *mask) return (1); } -#define ksiginfo_init(ksi) \ +#define ksiginfo_init(ksi) \ do { \ bzero(ksi, sizeof(ksiginfo_t)); \ } while(0) -#define ksiginfo_init_trap(ksi) \ +#define ksiginfo_init_trap(ksi) \ do { \ ksiginfo_t *kp = ksi; \ bzero(kp, sizeof(ksiginfo_t)); \ @@ -295,56 +295,51 @@ ksiginfo_copy(ksiginfo_t *src, ksiginfo_t *dst) } struct pgrp; -struct thread; struct proc; struct sigio; -struct mtx; - -extern int sugid_coredump; /* Sysctl variable kern.sugid_coredump */ -extern struct mtx sigio_lock; -extern int kern_logsigexit; /* Sysctl variable kern.logsigexit */ +struct thread; /* * Lock the pointers for a sigio object in the underlying objects of * a file descriptor. */ -#define SIGIO_LOCK() mtx_lock(&sigio_lock) -#define SIGIO_TRYLOCK() mtx_trylock(&sigio_lock) -#define SIGIO_UNLOCK() mtx_unlock(&sigio_lock) -#define SIGIO_LOCKED() mtx_owned(&sigio_lock) -#define SIGIO_ASSERT(type) mtx_assert(&sigio_lock, type) +#define SIGIO_LOCK() mtx_lock(&sigio_lock) +#define SIGIO_TRYLOCK() mtx_trylock(&sigio_lock) +#define SIGIO_UNLOCK() mtx_unlock(&sigio_lock) +#define SIGIO_LOCKED() mtx_owned(&sigio_lock) +#define SIGIO_ASSERT(type) mtx_assert(&sigio_lock, type) + +extern struct mtx sigio_lock; -/* stop_allowed parameter for cursig */ +/* Values for stop_allowed parameter for cursig(). */ #define SIG_STOP_ALLOWED 100 #define SIG_STOP_NOT_ALLOWED 101 -/* flags for kern_sigprocmask */ +/* Flags for kern_sigprocmask(). */ #define SIGPROCMASK_OLD 0x0001 #define SIGPROCMASK_PROC_LOCKED 0x0002 #define SIGPROCMASK_PS_LOCKED 0x0004 -/* - * Machine-independent functions: - */ int cursig(struct thread *td, int stop_allowed); void execsigs(struct proc *p); void gsignal(int pgid, int sig, ksiginfo_t *ksi); void killproc(struct proc *p, char *why); -ksiginfo_t * ksiginfo_alloc(int); -void ksiginfo_free(ksiginfo_t *); +ksiginfo_t * ksiginfo_alloc(int wait); +void ksiginfo_free(ksiginfo_t *ksi); int pksignal(struct proc *p, int sig, ksiginfo_t *ksi); -void pgsigio(struct sigio **, int signum, int checkctty); +void pgsigio(struct sigio **sigiop, int sig, int checkctty); void pgsignal(struct pgrp *pgrp, int sig, int checkctty, ksiginfo_t *ksi); int postsig(int sig); void psignal(struct proc *p, int sig); -int psignal_event(struct proc *p, struct sigevent *, ksiginfo_t *); +int psignal_event(struct proc *p, struct sigevent *sigev, ksiginfo_t *ksi); int ptracestop(struct thread *td, int sig); +void sendsig(sig_t catcher, ksiginfo_t *ksi, sigset_t *retmask); struct sigacts *sigacts_alloc(void); void sigacts_copy(struct sigacts *dest, struct sigacts *src); void sigacts_free(struct sigacts *ps); struct sigacts *sigacts_hold(struct sigacts *ps); int sigacts_shared(struct sigacts *ps); -void sigexit(struct thread *td, int signum) __dead2; +void sigexit(struct thread *td, int sig) __dead2; int sig_ffs(sigset_t *set); void siginit(struct proc *p); void signotify(struct thread *td); @@ -356,12 +351,7 @@ void sigqueue_take(ksiginfo_t *ksi); void tdksignal(struct thread *td, int sig, ksiginfo_t *ksi); void tdsigcleanup(struct thread *td); void tdsignal(struct thread *td, int sig); -void trapsignal(struct thread *td, ksiginfo_t *); - -/* - * Machine-dependent functions: - */ -void sendsig(sig_t, ksiginfo_t *, sigset_t *retmask); +void trapsignal(struct thread *td, ksiginfo_t *ksi); #endif /* _KERNEL */ |