summaryrefslogtreecommitdiffhomepage
path: root/lib/fs.c
diff options
context:
space:
mode:
authorJo-Philipp Wich <jo@mein.io>2020-11-15 17:22:29 +0100
committerJo-Philipp Wich <jo@mein.io>2020-11-15 17:22:29 +0100
commitd0ede0646f231179b3eab5a7aa4ab1e399f7c5be (patch)
treecc08d877c691c36275f28af6f21b56be0d8838ce /lib/fs.c
parent6cec0d369192f43d87680a3f807054659206f713 (diff)
fs: extend process close() function to return program exit code
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
Diffstat (limited to 'lib/fs.c')
-rw-r--r--lib/fs.c14
1 files changed, 12 insertions, 2 deletions
diff --git a/lib/fs.c b/lib/fs.c
index 261094e..4eb1436 100644
--- a/lib/fs.c
+++ b/lib/fs.c
@@ -171,14 +171,24 @@ static struct json_object *
ut_fs_pclose(struct ut_state *s, uint32_t off, struct json_object *args)
{
FILE **fp = (FILE **)ops->get_type(s->ctx, "fs.proc");
+ int rc;
if (!fp || !*fp)
err_return(EBADF);
- pclose(*fp);
+ rc = pclose(*fp);
*fp = NULL;
- return json_object_new_boolean(true);
+ if (rc == -1)
+ err_return(errno);
+
+ if (WIFEXITED(rc))
+ return xjs_new_int64(WEXITSTATUS(rc));
+
+ if (WIFSIGNALED(rc))
+ return xjs_new_int64(-WTERMSIG(rc));
+
+ return xjs_new_int64(0);
}
static struct json_object *