coreadm.2 (2010 09)

c
coreadm(2) coreadm(2)
c_out If non-NULL, the current settings are returned in this parameter.
RETURN VALUE
Upon successful completion,
coreadm() returns 0. Otherwise, a value of -1 is returned and
errno is
set to indicate the error.
ERRORS
[EPERM]
coreadm() fails and does not change the core file settings if the effective user-ID of the
calling process is not a user having appropriate privileges.
[EFAULT] The input or output parameter passed to
coreadm() is an invalid address.
[EINVAL] The core file pattern or flags is invalid.
[ESRCH] The specified PID is non-zero and does not exist.
EXAMPLES
1. Enable global core file creation using the pattern (core.process-ID.machine-name) in the location
/mnt/cores.
#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);
}
}
2. Enable per-process core file pattern for the process-ID passed in as argument. The core file will be
placed in PWD/corefle. The pattern is (core.process-ID.time-stamp ).
#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) {
2 Hewlett-Packard Company 2 HP-UX 11i Version 3: September 2010