United States-English |
|
|
HP-UX Reference > Ccoreadm(2)HP-UX 11i Version 3: February 2007 |
|
NAMEcoreadm — application core file administration SYNOPSIS#include <core.h> int coreadm(int c_version, pid_t c_pid, core_file_settings_t *c_in, core_file_settings_t *c_out); DESCRIPTIONcoreadm() system call is used to specify the location and pattern for core files produced by abnormally terminating processes. See core(4). This system call can be used to specify a system wide location for core file placement and/or a process specific pattern. The structure, corefile_settings_t is used to specify a system wide or a per-process core file pattern and also specify the current system wide core file settings. corefile_settings_t is defined in the header <core.h>.
Parametersc_version is expected to be set to COREADM_VERSION. It is critical for future backward compatibility that the COREADM_VERSION macro itself be used and not its value. c_pattern is the core file pattern. A core file name pattern is a normal file system path name with embedded variables, specified with a leading % character, that are expanded from values in effect when a core file is generated by the operating system. An expanded pattern length greater than MAXPATHLEN will be truncated to MAXPATHLEN. The possible values are: %p process ID %xp Process ID in hex %u effective user-ID %xu effective user-ID in Hex %g effective group-ID %xg effective group-ID in Hex %c thread's CPU number when the core file was created %f executable file name, up to a maximum of MAXCOMMLEN characters %n system node name (uname -n) %t time-stamp (in UTC time format) %% literal % c_flags is used to control the system wide core file settings. The flag values can be combination of
If a flag value is not set, then the option is disabled. For per-process core file setting, c_flags can either be 0 or COREADM_PROC_ENABLED. The former disables core file creation (for that process) and the latter enables it.
RETURN VALUEUpon successful completion, coreadm() returns 0. Otherwise, a value of -1 is returned and errno is set to indicate the error. ERRORS
EXAMPLES
#include <stdio.h> #include <stdlib.h> #include <errno.h> #include <limits.h> #include <sys/types.h> #include <sys/core.h> main() { corefile_settings_t c_in, c_out; int ret; bzero(&c_in, sizeof(c_in)); bzero(&c_out,sizeof(c_out)); /* Read the current settings. */ ret = coreadm(COREADM_VERSION, (pid_t)0, \ (corefile_settings_t *) NULL, &c_out); if (ret) { perror("coreadm"); exit(ret); } /* Setup new core settings. */ strcpy(c_in.c_pattern,"/mnt/cores/core.%p.%n"); c_in.c_flags = c_out.c_flags | COREADM_GLOB_ENABLED; /* Set the new values. */ ret = coreadm(COREADM_VERSION, (pid_t)0, &c_in, &c_out); if (ret) { perror("coreadm"); exit(ret); } }
#include <stdio.h> #include <stdlib.h> #include <errno.h> #include <sys/param.h> #include <sys/core.h> #include <sys/types.h> #include <string.h> main(int argc, char **argv) { corefile_settings_t c_in, c_out; int ret; if (argc < 2) { fprintf(stderr,"Usage %s <PID>\n", argv[0]); exit(2); } bzero(&c_in, sizeof(c_in)); bzero(&c_out,sizeof(c_out)); strcpy(c_in.c_pattern,"core.%p.%t"); c_in.c_flags = COREADM_PROC_ENABLED; /* Read the current settings. */ ret = coreadm(COREADM_VERSION, (pid_t)0, \ (corefile_settings_t *) NULL, &c_out); if (ret) { perror("coreadm"); exit(ret); } if ((c_out.c_flags & COREADM_PROC_ENABLED) == 0) { fprintf(stdout, "Warning: System wide Per-process core file dumping\ currently disabled."); } /* Set the new values. */ ret = coreadm(COREADM_VERSION, strtol(argv[1], (char **)NULL, 10),\ &c_in, &c_out); if (ret) { perror("coreadm"); exit(ret); } }
#include <stdio.h> #include <stdlib.h> #include <errno.h> #include <sys/param.h> #include <sys/core.h> #include <sys/types.h> #include <string.h> main(int argc, char **argv) { corefile_settings_t c_in, c_out; int ret; bzero(&c_in, sizeof(c_in)); bzero(&c_out,sizeof(c_out)); strcpy(c_in.c_pattern, "core.%c"); c_in.c_flags = COREADM_PROC_ENABLED; /* Read the current settings. */ ret = coreadm(COREADM_VERSION, (pid_t)0, \ (corefile_settings_t *) NULL, &c_out); if (ret) { perror("coreadm"); exit(ret); } if ((c_out.c_flags & COREADM_PROC_ENABLED) == 0) { /* If core file creation is disabled, enable it. */ bcopy(&c_out, &c_in, sizeof c_out); c_in.c_flags |= COREADM_PROC_ENABLED; ret = coreadm(COREADM_VERSION, 0, &c_in,\ (corefile_settings_t *)NULL); } /* Set the new values. */ ret = coreadm(COREADM_VERSION, 1 , &c_in, &c_out); if (ret) { perror("coreadm"); exit(ret); } } |
Printable version | ||
|