summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-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 *