1/*
2 * Copyright (c) 1982, 1986, 1989, 1991, 1993
3 * The Regents of the University of California. All rights reserved.
4 * (c) UNIX System Laboratories, Inc.
5 * All or some portions of this file are derived from material licensed
6 * to the University of California by American Telephone and Telegraph
7 * Co. or Unix System Laboratories, Inc. and are reproduced herein with
8 * the permission of UNIX System Laboratories, Inc.
--- 22 unchanged lines hidden (view full) ---
31 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
32 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
33 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
34 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
35 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
36 * SUCH DAMAGE.
37 *
38 * @(#)kern_sig.c 8.7 (Berkeley) 4/18/94
39 * $FreeBSD: head/sys/kern/kern_sig.c 50477 1999-08-28 01:08:13Z peter $
40 */
41
42#include "opt_compat.h"
43#include "opt_ktrace.h"
44
45#define SIGPROP /* include signal properties table */
46#include <sys/param.h>
47#include <sys/kernel.h>
--- 18 unchanged lines hidden (view full) ---
66#include <machine/cpu.h>
67#ifdef SMP
68#include <machine/smp.h>
69#endif
70
71static int killpg1 __P((struct proc *cp, int signum, int pgid, int all));
72static void setsigvec __P((struct proc *p, int signum, struct sigaction *sa));
73static void stop __P((struct proc *));
74
75static int kern_logsigexit = 1;
76SYSCTL_INT(_kern, KERN_LOGSIGEXIT, logsigexit, CTLFLAG_RW,
77 &kern_logsigexit, 0,
78 "Log processes quitting on abnormal signals to syslog(3)");
79
80/*
81 * Can process p, with pcred pc, send the signal signum to process q?
--- 1168 unchanged lines hidden (view full) ---
1250 if (sigprop[signum] & SA_CORE) {
1251 p->p_sig = signum;
1252 /*
1253 * Log signals which would cause core dumps
1254 * (Log as LOG_INFO to appease those who don't want
1255 * these messages.)
1256 * XXX : Todo, as well as euid, write out ruid too
1257 */
1258 if (p->p_sysent->sv_coredump != NULL &&
1259 (*p->p_sysent->sv_coredump)(p) == 0)
1260 signum |= WCOREFLAG;
1261 if (kern_logsigexit)
1262 log(LOG_INFO,
1263 "pid %d (%s), uid %d: exited on signal %d%s\n",
1264 p->p_pid, p->p_comm,
1265 p->p_cred && p->p_ucred ? p->p_ucred->cr_uid : -1,
1266 signum &~ WCOREFLAG,
1267 signum & WCOREFLAG ? " (core dumped)" : "");
--- 13 unchanged lines hidden (view full) ---
1281 * %N name of process ("name")
1282 * %P process id (pid)
1283 * %U user id (uid)
1284 * For example, "%N.core" is the default; they can be disabled completely
1285 * by using "/dev/null", or all core files can be stored in "/cores/%U/%N-%P".
1286 * This is controlled by the sysctl variable kern.corefile (see above).
1287 */
1288
1289char *
1290expand_name(name, uid, pid)
1291const char *name; uid_t uid; pid_t pid; {
1292 char *temp;
1293 char buf[11]; /* Buffer for pid/uid -- max 4B */
1294 int i, n;
1295 char *format = corefilename;
1296 size_t namelen;
1297
--- 50 unchanged lines hidden (view full) ---
1348 temp[n++] = format[i];
1349 }
1350 }
1351 temp[n] = '\0';
1352 return temp;
1353}
1354
1355/*
1356 * Nonexistent system call-- signal process (may want to handle it).
1357 * Flag error in case process won't see signal immediately (blocked or ignored).
1358 */
1359#ifndef _SYS_SYSPROTO_H_
1360struct nosys_args {
1361 int dummy;
1362};
1363#endif
--- 37 unchanged lines hidden ---
2 * Copyright (c) 1982, 1986, 1989, 1991, 1993
3 * The Regents of the University of California. All rights reserved.
4 * (c) UNIX System Laboratories, Inc.
5 * All or some portions of this file are derived from material licensed
6 * to the University of California by American Telephone and Telegraph
7 * Co. or Unix System Laboratories, Inc. and are reproduced herein with
8 * the permission of UNIX System Laboratories, Inc.
--- 22 unchanged lines hidden (view full) ---
31 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
32 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
33 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
34 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
35 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
36 * SUCH DAMAGE.
37 *
38 * @(#)kern_sig.c 8.7 (Berkeley) 4/18/94
39 * $FreeBSD: head/sys/kern/kern_sig.c 50477 1999-08-28 01:08:13Z peter $
40 */
41
42#include "opt_compat.h"
43#include "opt_ktrace.h"
44
45#define SIGPROP /* include signal properties table */
46#include <sys/param.h>
47#include <sys/kernel.h>
--- 18 unchanged lines hidden (view full) ---
66#include <machine/cpu.h>
67#ifdef SMP
68#include <machine/smp.h>
69#endif
70
71static int killpg1 __P((struct proc *cp, int signum, int pgid, int all));
72static void setsigvec __P((struct proc *p, int signum, struct sigaction *sa));
73static void stop __P((struct proc *));
74
75static int kern_logsigexit = 1;
76SYSCTL_INT(_kern, KERN_LOGSIGEXIT, logsigexit, CTLFLAG_RW,
77 &kern_logsigexit, 0,
78 "Log processes quitting on abnormal signals to syslog(3)");
79
80/*
81 * Can process p, with pcred pc, send the signal signum to process q?
--- 1168 unchanged lines hidden (view full) ---
1250 if (sigprop[signum] & SA_CORE) {
1251 p->p_sig = signum;
1252 /*
1253 * Log signals which would cause core dumps
1254 * (Log as LOG_INFO to appease those who don't want
1255 * these messages.)
1256 * XXX : Todo, as well as euid, write out ruid too
1257 */
1258 if (p->p_sysent->sv_coredump != NULL &&
1259 (*p->p_sysent->sv_coredump)(p) == 0)
1260 signum |= WCOREFLAG;
1261 if (kern_logsigexit)
1262 log(LOG_INFO,
1263 "pid %d (%s), uid %d: exited on signal %d%s\n",
1264 p->p_pid, p->p_comm,
1265 p->p_cred && p->p_ucred ? p->p_ucred->cr_uid : -1,
1266 signum &~ WCOREFLAG,
1267 signum & WCOREFLAG ? " (core dumped)" : "");
--- 13 unchanged lines hidden (view full) ---
1281 * %N name of process ("name")
1282 * %P process id (pid)
1283 * %U user id (uid)
1284 * For example, "%N.core" is the default; they can be disabled completely
1285 * by using "/dev/null", or all core files can be stored in "/cores/%U/%N-%P".
1286 * This is controlled by the sysctl variable kern.corefile (see above).
1287 */
1288
1289char *
1290expand_name(name, uid, pid)
1291const char *name; uid_t uid; pid_t pid; {
1292 char *temp;
1293 char buf[11]; /* Buffer for pid/uid -- max 4B */
1294 int i, n;
1295 char *format = corefilename;
1296 size_t namelen;
1297
--- 50 unchanged lines hidden (view full) ---
1348 temp[n++] = format[i];
1349 }
1350 }
1351 temp[n] = '\0';
1352 return temp;
1353}
1354
1355/*
1356 * Nonexistent system call-- signal process (may want to handle it).
1357 * Flag error in case process won't see signal immediately (blocked or ignored).
1358 */
1359#ifndef _SYS_SYSPROTO_H_
1360struct nosys_args {
1361 int dummy;
1362};
1363#endif
--- 37 unchanged lines hidden ---