Allow -c argument now.
This commit is contained in:
parent
e34a3b7f08
commit
089038b4a1
@ -1,4 +1,4 @@
|
||||
.\" $NetBSD: gcore.1,v 1.10 2004/12/01 12:02:08 wiz Exp $
|
||||
.\" $NetBSD: gcore.1,v 1.11 2005/01/09 17:47:45 christos Exp $
|
||||
.\"
|
||||
.\" Copyright (c) 2003 The NetBSD Foundation, Inc.
|
||||
.\" All rights reserved.
|
||||
@ -35,7 +35,7 @@
|
||||
.\" POSSIBILITY OF SUCH DAMAGE.
|
||||
.\"
|
||||
.\"
|
||||
.Dd January 23, 2003
|
||||
.Dd January 9, 2004
|
||||
.Dt GCORE 1
|
||||
.Os
|
||||
.Sh NAME
|
||||
@ -43,6 +43,7 @@
|
||||
.Nd get core images of running process
|
||||
.Sh SYNOPSIS
|
||||
.Nm
|
||||
.Op Fl c Ar corename
|
||||
.Ar pid
|
||||
.Op Ar pid ...
|
||||
.Sh DESCRIPTION
|
||||
@ -56,7 +57,9 @@ where
|
||||
.Dq Aq Pa progname
|
||||
is the program name of the process corresponding to the pid that is given on
|
||||
the command line.
|
||||
This filename can be changed by setting
|
||||
This filename can be changed by supplying the
|
||||
.Fl c Ar corename
|
||||
argument, or setting
|
||||
.Dq Pa proc.\*[Lt]pid\*[Gt].corename
|
||||
with
|
||||
.Xr sysctl 8 .
|
||||
@ -75,6 +78,5 @@ appeared in BSD 4.2, disappeared in
|
||||
and reappeared in
|
||||
.Nx 2.0 .
|
||||
.Sh BUGS
|
||||
The
|
||||
.Op Fl o Ar corename
|
||||
option is not implemented.
|
||||
The process is not stopped while the core file is generated, so it might
|
||||
not be consistent.
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: gcore.c,v 1.7 2004/01/05 23:23:34 jmmv Exp $ */
|
||||
/* $NetBSD: gcore.c,v 1.8 2005/01/09 17:47:45 christos Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 2003 The NetBSD Foundation, Inc.
|
||||
@ -37,7 +37,7 @@
|
||||
*/
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
__RCSID("$NetBSD: gcore.c,v 1.7 2004/01/05 23:23:34 jmmv Exp $");
|
||||
__RCSID("$NetBSD: gcore.c,v 1.8 2005/01/09 17:47:45 christos Exp $");
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <sys/param.h>
|
||||
@ -46,6 +46,7 @@ __RCSID("$NetBSD: gcore.c,v 1.7 2004/01/05 23:23:34 jmmv Exp $");
|
||||
#include <sys/proc.h>
|
||||
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <err.h>
|
||||
#include <limits.h>
|
||||
#include <stdlib.h>
|
||||
@ -57,7 +58,8 @@ static void usage(void) __attribute__((__noreturn__));
|
||||
static void
|
||||
usage(void)
|
||||
{
|
||||
(void)fprintf(stderr, "usage: %s <pid> [<pid> ...]\n", getprogname());
|
||||
(void)fprintf(stderr, "Usage: %s [-c <corename>] <pid> [<pid> ...]\n",
|
||||
getprogname());
|
||||
exit(1);
|
||||
}
|
||||
|
||||
@ -66,12 +68,15 @@ int
|
||||
main(int argc, char **argv)
|
||||
{
|
||||
int c;
|
||||
char *corename = NULL;
|
||||
int corelen = 0;
|
||||
|
||||
while ((c = getopt(argc, argv, "o:")) != -1)
|
||||
while ((c = getopt(argc, argv, "c:")) != -1)
|
||||
switch (c) {
|
||||
case 'o':
|
||||
errx(1, "-o is not supported yet.");
|
||||
/*NOTREACHED*/
|
||||
case 'c':
|
||||
corename = optarg;
|
||||
corelen = strlen(corename);
|
||||
break;
|
||||
case '?':
|
||||
default:
|
||||
usage();
|
||||
@ -91,7 +96,7 @@ main(int argc, char **argv)
|
||||
errx(1, "`%s' is not a number.", argv[c]);
|
||||
if (errno == ERANGE && (lval == LONG_MAX || lval == LONG_MIN))
|
||||
err(1, "Pid `%s'", argv[c]);
|
||||
if (ptrace(PT_DUMPCORE, (pid_t)lval, NULL, 0) == -1)
|
||||
if (ptrace(PT_DUMPCORE, (pid_t)lval, corename, corelen) == -1)
|
||||
err(1, "ptrace(PT_DUMPCORE) failed");
|
||||
}
|
||||
return 0;
|
||||
|
Loading…
Reference in New Issue
Block a user