summaryrefslogtreecommitdiff
path: root/usr.bin/pmdb/process.c
diff options
context:
space:
mode:
authorFederico G. Schwindt <fgsch@cvs.openbsd.org>2002-03-19 07:26:59 +0000
committerFederico G. Schwindt <fgsch@cvs.openbsd.org>2002-03-19 07:26:59 +0000
commit122e89f94c0becf35865c08002937cfafdd53f34 (patch)
tree8e27c4386320558a84ca3bfdd13c7420587d990e /usr.bin/pmdb/process.c
parent83c5280f739f84f8b822a82506d1d80f766c112a (diff)
o check if the file is exists, is readable and executable before going
further. o rearrange includes.
Diffstat (limited to 'usr.bin/pmdb/process.c')
-rw-r--r--usr.bin/pmdb/process.c16
1 files changed, 12 insertions, 4 deletions
diff --git a/usr.bin/pmdb/process.c b/usr.bin/pmdb/process.c
index 3c08fa711bd..1e7f1d694ab 100644
--- a/usr.bin/pmdb/process.c
+++ b/usr.bin/pmdb/process.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: process.c,v 1.2 2002/03/15 16:41:06 jason Exp $ */
+/* $OpenBSD: process.c,v 1.3 2002/03/19 07:26:58 fgsch Exp $ */
/*
* Copyright (c) 2002 Artur Grabowski <art@openbsd.org>
* All rights reserved.
@@ -27,11 +27,13 @@
#include <sys/types.h>
#include <sys/ptrace.h>
#include <sys/wait.h>
-#include <stdlib.h>
-#include <stdio.h>
+#include <err.h>
+#include <errno.h>
#include <signal.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
#include <unistd.h>
-#include <err.h>
#include "pmdb.h"
#include "symbol.h"
@@ -45,6 +47,12 @@ process_load(struct pstate *ps)
if (ps->ps_state == LOADED)
return (0);
+ if (access(*ps->ps_argv, R_OK|X_OK) < 0) {
+ fprintf(stderr, "%s: %s.\n", *ps->ps_argv,
+ strerror(errno));
+ return (0);
+ }
+
switch (ps->ps_pid = fork()) {
case 0:
if (ptrace(PT_TRACE_ME, getpid(), NULL, 0) != 0)