Changeset View
Changeset View
Standalone View
Standalone View
sys/kern/kern_sig.c
Show All 32 Lines | |||||
* | * | ||||
* @(#)kern_sig.c 8.7 (Berkeley) 4/18/94 | * @(#)kern_sig.c 8.7 (Berkeley) 4/18/94 | ||||
*/ | */ | ||||
#include <sys/cdefs.h> | #include <sys/cdefs.h> | ||||
__FBSDID("$FreeBSD$"); | __FBSDID("$FreeBSD$"); | ||||
#include "opt_compat.h" | #include "opt_compat.h" | ||||
#include "opt_gzio.h" | |||||
#include "opt_ktrace.h" | #include "opt_ktrace.h" | ||||
#include "opt_core.h" | |||||
#include <sys/param.h> | #include <sys/param.h> | ||||
#include <sys/ctype.h> | #include <sys/ctype.h> | ||||
#include <sys/systm.h> | #include <sys/systm.h> | ||||
#include <sys/signalvar.h> | #include <sys/signalvar.h> | ||||
#include <sys/vnode.h> | #include <sys/vnode.h> | ||||
#include <sys/acct.h> | #include <sys/acct.h> | ||||
#include <sys/bus.h> | #include <sys/bus.h> | ||||
▲ Show 20 Lines • Show All 3,019 Lines • ▼ Show 20 Lines | sysctl_debug_num_cores_check (SYSCTL_HANDLER_ARGS) | ||||
if (new_val < 0) | if (new_val < 0) | ||||
new_val = 0; | new_val = 0; | ||||
num_cores = new_val; | num_cores = new_val; | ||||
return (0); | return (0); | ||||
} | } | ||||
SYSCTL_PROC(_debug, OID_AUTO, ncores, CTLTYPE_INT|CTLFLAG_RW, | SYSCTL_PROC(_debug, OID_AUTO, ncores, CTLTYPE_INT|CTLFLAG_RW, | ||||
0, sizeof(int), sysctl_debug_num_cores_check, "I", ""); | 0, sizeof(int), sysctl_debug_num_cores_check, "I", ""); | ||||
#if defined(COMPRESS_USER_CORES) | #ifdef GZIO | ||||
int compress_user_cores = 1; | int compress_user_cores = 1; | ||||
SYSCTL_INT(_kern, OID_AUTO, compress_user_cores, CTLFLAG_RW, | SYSCTL_INT(_kern, OID_AUTO, compress_user_cores, CTLFLAG_RW, | ||||
&compress_user_cores, 0, "Compression of user corefiles"); | &compress_user_cores, 0, "Compression of user corefiles"); | ||||
int compress_user_cores_gzlevel = -1; /* default level */ | int compress_user_cores_gzlevel = 6; | ||||
SYSCTL_INT(_kern, OID_AUTO, compress_user_cores_gzlevel, CTLFLAG_RW, | SYSCTL_INT(_kern, OID_AUTO, compress_user_cores_gzlevel, CTLFLAG_RW, | ||||
&compress_user_cores_gzlevel, -1, "Corefile gzip compression level"); | &compress_user_cores_gzlevel, 0, "Corefile gzip compression level"); | ||||
#define GZ_SUFFIX ".gz" | #define GZ_SUFFIX ".gz" | ||||
#define GZ_SUFFIX_LEN 3 | #endif /* GZIO */ | ||||
#endif | |||||
static char corefilename[MAXPATHLEN] = {"%N.core"}; | static char corefilename[MAXPATHLEN] = {"%N.core"}; | ||||
SYSCTL_STRING(_kern, OID_AUTO, corefile, CTLFLAG_RWTUN, corefilename, | SYSCTL_STRING(_kern, OID_AUTO, corefile, CTLFLAG_RWTUN, corefilename, | ||||
sizeof(corefilename), "Process corefile name format string"); | sizeof(corefilename), "Process corefile name format string"); | ||||
/* | /* | ||||
* corefile_open(comm, uid, pid, td, compress, vpp, namep) | * corefile_open(comm, uid, pid, td, compress, vpp, namep) | ||||
* Expand the name described in corefilename, using name, uid, and pid | * Expand the name described in corefilename, using name, uid, and pid | ||||
▲ Show 20 Lines • Show All 59 Lines • ▼ Show 20 Lines | case '%': /* Format character */ | ||||
} | } | ||||
break; | break; | ||||
default: | default: | ||||
sbuf_putc(&sb, format[i]); | sbuf_putc(&sb, format[i]); | ||||
break; | break; | ||||
} | } | ||||
} | } | ||||
free(hostname, M_TEMP); | free(hostname, M_TEMP); | ||||
#ifdef COMPRESS_USER_CORES | #ifdef GZIO | ||||
if (compress) | if (compress) | ||||
sbuf_printf(&sb, GZ_SUFFIX); | sbuf_printf(&sb, GZ_SUFFIX); | ||||
#endif | #endif | ||||
if (sbuf_error(&sb) != 0) { | if (sbuf_error(&sb) != 0) { | ||||
log(LOG_ERR, "pid %ld (%s), uid (%lu): corename is too " | log(LOG_ERR, "pid %ld (%s), uid (%lu): corename is too " | ||||
"long\n", (long)pid, comm, (u_long)uid); | "long\n", (long)pid, comm, (u_long)uid); | ||||
sbuf_delete(&sb); | sbuf_delete(&sb); | ||||
free(name, M_TEMP); | free(name, M_TEMP); | ||||
▲ Show 20 Lines • Show All 88 Lines • ▼ Show 20 Lines | coredump(struct thread *td) | ||||
off_t limit; | off_t limit; | ||||
int compress; | int compress; | ||||
char *data = NULL; | char *data = NULL; | ||||
char *fullpath, *freepath = NULL; | char *fullpath, *freepath = NULL; | ||||
size_t len; | size_t len; | ||||
static const char comm_name[] = "comm="; | static const char comm_name[] = "comm="; | ||||
static const char core_name[] = "core="; | static const char core_name[] = "core="; | ||||
#ifdef COMPRESS_USER_CORES | #ifdef GZIO | ||||
compress = compress_user_cores; | compress = compress_user_cores; | ||||
#else | #else | ||||
compress = 0; | compress = 0; | ||||
#endif | #endif | ||||
PROC_LOCK_ASSERT(p, MA_OWNED); | PROC_LOCK_ASSERT(p, MA_OWNED); | ||||
MPASS((p->p_flag & P_HADTHREADS) == 0 || p->p_singlethread == td); | MPASS((p->p_flag & P_HADTHREADS) == 0 || p->p_singlethread == td); | ||||
_STOPEVENT(p, S_CORE, 0); | _STOPEVENT(p, S_CORE, 0); | ||||
▲ Show 20 Lines • Show All 262 Lines • Show Last 20 Lines |