coreadm.2 (2010 09)

c
coreadm(2) coreadm(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);
}
}
3. Enable a per-process pattern of core.CUP-ID for all processes in the system (init (1M) core file set-
ting). NOTE: This has to be run during system startup or reboot the machine after setting this for the
settings to take full effect.
#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);
HP-UX 11i Version 3: September 2010 3 Hewlett-Packard Company 3