diff options
author | Guillem Jover <guillem@debian.org> | 2014-10-05 01:48:52 +0200 |
---|---|---|
committer | Guillem Jover <guillem@debian.org> | 2014-10-06 00:48:12 +0200 |
commit | 90c2e4c9e0231b15d4f93be120fcc01dd22ea82e (patch) | |
tree | df7029b0cfea270da83d954cef5269dc65ecd102 /utils/start-stop-daemon.c | |
parent | 8fbe533b5b335ca08c0478687ea30a9a96f3fc6a (diff) | |
download | dpkg-90c2e4c9e0231b15d4f93be120fcc01dd22ea82e.tar.gz |
s-s-d: Do not fail when kvm_getprocs() cannot find any process
Return NULL, and let the call sites return false themselves. This fixes
the code failing on retries when the process has disappeared.
Diffstat (limited to 'utils/start-stop-daemon.c')
-rw-r--r-- | utils/start-stop-daemon.c | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/utils/start-stop-daemon.c b/utils/start-stop-daemon.c index 64a631a7e..3411dfdec 100644 --- a/utils/start-stop-daemon.c +++ b/utils/start-stop-daemon.c @@ -1252,7 +1252,7 @@ ssd_kvm_get_procs(kvm_t *kd, int op, int arg, int *count) *count = 0; kp = kvm_getprocs(kd, op, arg, count); - if (kp == NULL) + if (kp == NULL && errno != ESRCH) errx(1, "%s", kvm_geterr(kd)); return kp; @@ -1361,6 +1361,8 @@ pid_is_exec(pid_t pid, const struct stat *esb) kd = ssd_kvm_open(); kp = ssd_kvm_get_procs(kd, KERN_PROC_PID, pid, NULL); + if (kp == NULL) + return false; pid_argv_p = kvm_getargv(kd, kp, argv_len); if (pid_argv_p == NULL) @@ -1445,6 +1447,8 @@ pid_is_child(pid_t pid, pid_t ppid) kd = ssd_kvm_open(); kp = ssd_kvm_get_procs(kd, KERN_PROC_PID, pid, NULL); + if (kp == NULL) + return false; #if defined(OSFreeBSD) proc_ppid = kp->ki_ppid; @@ -1501,6 +1505,8 @@ pid_is_user(pid_t pid, uid_t uid) kd = ssd_kvm_open(); kp = ssd_kvm_get_procs(kd, KERN_PROC_PID, pid, NULL); + if (kp == NULL) + return false; #if defined(OSFreeBSD) proc_uid = kp->ki_ruid; @@ -1583,6 +1589,8 @@ pid_is_cmd(pid_t pid, const char *name) kd = ssd_kvm_open(); kp = ssd_kvm_get_procs(kd, KERN_PROC_PID, pid, NULL); + if (kp == NULL) + return false; #if defined(OSFreeBSD) process_name = kp->ki_comm; |