Skip to content

Commit

Permalink
Use waitpid() in a portable fashion
Browse files Browse the repository at this point in the history
The status value set by waitpid() needs to be manipulated using
WIFEXITED() and WEXITSTATUS() macros to be portable.
  • Loading branch information
dlenski committed Aug 6, 2018
1 parent 42918c3 commit f06b564
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions gpst.c
Expand Up @@ -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);
Expand Down

0 comments on commit f06b564

Please sign in to comment.