diff options
author | alfred <alfred@FreeBSD.org> | 2005-03-27 12:53:25 +0000 |
---|---|---|
committer | alfred <alfred@FreeBSD.org> | 2005-03-27 12:53:25 +0000 |
commit | 12a374aa6088b0eb31226b5e9eeee6dd6343dd45 (patch) | |
tree | a1b2cec0056530ec8694892f5448c40a19ca65f0 /usr.bin | |
parent | 9e2b623bb53bb398a766b27fc6714ca9564ca285 (diff) | |
download | FreeBSD-src-12a374aa6088b0eb31226b5e9eeee6dd6343dd45.zip FreeBSD-src-12a374aa6088b0eb31226b5e9eeee6dd6343dd45.tar.gz |
When doing the initial open of the proc via procfs, complain if we are
unable to open the /proc/pid/mem file. Otherwise doing a truss on
a nonexistant pid makes us return success even though no such process
exists.
Diffstat (limited to 'usr.bin')
-rw-r--r-- | usr.bin/truss/extern.h | 2 | ||||
-rw-r--r-- | usr.bin/truss/main.c | 14 | ||||
-rw-r--r-- | usr.bin/truss/setup.c | 6 |
3 files changed, 14 insertions, 8 deletions
diff --git a/usr.bin/truss/extern.h b/usr.bin/truss/extern.h index ee977fb..e13f80b 100644 --- a/usr.bin/truss/extern.h +++ b/usr.bin/truss/extern.h @@ -32,7 +32,7 @@ */ extern int setup_and_wait(char **); -extern int start_tracing(int, int, int); +extern int start_tracing(int, int, int, int); extern void restore_proc(int); extern const char *ioctlname(register_t val); extern char *strsig(int sig); diff --git a/usr.bin/truss/main.c b/usr.bin/truss/main.c index ce61db2..9d289a7 100644 --- a/usr.bin/truss/main.c +++ b/usr.bin/truss/main.c @@ -165,12 +165,16 @@ main(int ac, char **av) char **command; struct procfs_status pfs; struct ex_types *funcs; - int in_exec = 0; - char *fname = NULL; - int sigexit = 0; + int in_exec, sigexit, initial_open; + char *fname; struct trussinfo *trussinfo; char *signame; + in_exec = 0; + sigexit = 0; + fname = NULL; + initial_open = 1; + /* Initialize the trussinfo struct */ trussinfo = (struct trussinfo *)malloc(sizeof(struct trussinfo)); if (trussinfo == NULL) @@ -246,9 +250,11 @@ main(int ac, char **av) START_TRACE: Procfd = start_tracing( - trussinfo->pid, S_EXEC | S_SCE | S_SCX | S_CORE | S_EXIT | + trussinfo->pid, initial_open, + S_EXEC | S_SCE | S_SCX | S_CORE | S_EXIT | ((trussinfo->flags & NOSIGS) ? 0 : S_SIG), ((trussinfo->flags & FOLLOWFORKS) ? PF_FORK : 0)); + initial_open = 0; if (Procfd == -1) return (0); diff --git a/usr.bin/truss/setup.c b/usr.bin/truss/setup.c index fa52dd6..c48370c 100644 --- a/usr.bin/truss/setup.c +++ b/usr.bin/truss/setup.c @@ -129,7 +129,7 @@ setup_and_wait(char *command[]) */ int -start_tracing(int pid, int eventflags, int flags) +start_tracing(int pid, int failisfatal, int eventflags, int flags) { int fd; char buf[32]; @@ -144,8 +144,8 @@ start_tracing(int pid, int eventflags, int flags) * happens with SUGID programs. So we need to see if it still * exists before we complain bitterly. */ - if (kill(pid, 0) == -1) - return -1; + if (!failisfatal && kill(pid, 0) == -1) + return (-1); err(8, "cannot open %s", buf); } |