]> www.infradead.org Git - users/dwmw2/openconnect.git/commitdiff
Use waitpid() in a portable fashion
authorDaniel Lenski <dlenski@gmail.com>
Mon, 6 Aug 2018 07:48:01 +0000 (00:48 -0700)
committerDaniel Lenski <dlenski@gmail.com>
Mon, 6 Aug 2018 18:48:15 +0000 (11:48 -0700)
The status value set by waitpid() needs to be manipulated using
WIFEXITED() and WEXITSTATUS() macros to be portable.

gpst.c

diff --git a/gpst.c b/gpst.c
index d09df69f123355bf3d2f1fc1b476f80bed340465..a396aa6934e5d12eb4228f8fbf878bfe66293d34 100644 (file)
--- a/gpst.c
+++ b/gpst.c
@@ -885,9 +885,15 @@ static int run_hip_script(struct openconnect_info *vpninfo)
                        buf_append_bytes(report_buf, b, i);
 
                waitpid(child, &status, 0);
-               if (status != 0) {
+               if (!WIFEXITED(status)) {
                        vpn_progress(vpninfo, PRG_ERR,
-                                                _("HIP script returned non-zero status: %d\n"), status);
+                                                _("HIP script '%s' exited abnormally\n"),
+                                                vpninfo->csd_wrapper);
+                       ret = -EINVAL;
+               } else if (WEXITSTATUS(status) != 0) {
+                       vpn_progress(vpninfo, PRG_ERR,
+                                                _("HIP script '%s' returned non-zero status: %d\n"),
+                                                vpninfo->csd_wrapper, WEXITSTATUS(status));
                        ret = -EINVAL;
                } else {
                        ret = check_or_submit_hip_report(vpninfo, report_buf->data);