[PATCH 6/5] Use waitpid() in a portable fashion

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



The status value set by waitpid() needs to be manipulated using
WIFEXITED() and WEXITSTATUS() macros to be portable.

Signed-off-by: Daniel Lenski <dlenski at gmail.com>
---
 gpst.c | 10 ++++++++--
 1 file changed, 8 insertions(+), 2 deletions(-)

diff --git a/gpst.c b/gpst.c
index d09df69..a396aa6 100644
--- 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);
-- 
2.7.4




[Index of Archives]     [Linux Samsung SoC]     [Linux Rockchip SoC]     [Linux Actions SoC]     [Linux for Synopsys ARC Processors]     [Linux NFS]     [Linux NILFS]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]


  Powered by Linux