From e475bd56d61fed83f59d6299525ddb69c50b6ab4 Mon Sep 17 00:00:00 2001 From: "Richard W.M. Jones" Date: Sun, 24 Jan 2016 14:39:19 +0000 Subject: [PATCH] Document how to handle errors from mexp_close. --- miniexpect.pod | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/miniexpect.pod b/miniexpect.pod index b4f0edc..827a268 100644 --- a/miniexpect.pod +++ b/miniexpect.pod @@ -186,6 +186,23 @@ This case should not necessarily be considered an error. =back +This is how code should check for and print errors from C: + + status = mexp_close (h); + if (status == -1) { + perror ("mexp_close"); + return -1; + } + if (WIFSIGNALED (status) && WTERMSIG (status) == SIGHUP) + goto ignore; /* not an error */ + if (!WIFEXITED (status) || WEXITSTATUS (status) != 0) + /* You could use the W* macros to print a better error message. */ + fprintf (stderr, "error: subprocess failed, status = %d", status); + return -1; + } + ignore: + /* no error case */ + =head1 EXPECT FUNCTION Miniexpect contains a powerful regular expression matching function -- 1.8.3.1