diff options
author | Philip Guenther <guenther@cvs.openbsd.org> | 2014-07-20 01:38:41 +0000 |
---|---|---|
committer | Philip Guenther <guenther@cvs.openbsd.org> | 2014-07-20 01:38:41 +0000 |
commit | 7a28608cfded6ad958b67771de221d7e4f65d5a4 (patch) | |
tree | c9cf52f6b8ea60c0fae8134d5226210f7c1d3ae8 /bin | |
parent | 86c2401ccbc07e58588ca73b92b27ab89e9e671f (diff) |
Make sure the correct errno is reported by warn* or err* and not
the errno of an intervening cleanup operation like close/unlink/etc.
Diff from Doug Hogan (doug (at) acyclic.org)
Diffstat (limited to 'bin')
-rw-r--r-- | bin/systrace/intercept.c | 14 |
1 files changed, 9 insertions, 5 deletions
diff --git a/bin/systrace/intercept.c b/bin/systrace/intercept.c index c3eb23ee9f1..00618f7ce5b 100644 --- a/bin/systrace/intercept.c +++ b/bin/systrace/intercept.c @@ -1,4 +1,4 @@ -/* $OpenBSD: intercept.c,v 1.61 2014/04/24 01:57:06 tedu Exp $ */ +/* $OpenBSD: intercept.c,v 1.62 2014/07/20 01:38:40 guenther Exp $ */ /* * Copyright 2002 Niels Provos <provos@citi.umich.edu> * All rights reserved. @@ -356,22 +356,26 @@ intercept_run(int bg, int *fdp, uid_t uid, gid_t gid, /* Setup done, restore signal handling state */ if (signal(SIGUSR1, ohandler) == SIG_ERR) { + int saved_errno = errno; kill(pid, SIGKILL); - err(1, "signal"); + errc(1, saved_errno, "signal"); } if (sigprocmask(SIG_SETMASK, &oset, NULL) == -1) { + int saved_errno = errno; kill(pid, SIGKILL); - err(1, "sigprocmask"); + errc(1, saved_errno, "sigprocmask"); } if (bg) { if (daemon(1, 1) == -1) { + int saved_errno = errno; kill(pid, SIGKILL); - err(1, "daemon"); + errc(1, saved_errno, "daemon"); } if ((*fdp = intercept_open()) == -1) { + int saved_errno = errno; kill(pid, SIGKILL); - err(1, "intercept_open"); + errc(1, saved_errno, "intercept_open"); } } |