Skip to content

Commit

Permalink
REBASE strengthen check_exec
Browse files Browse the repository at this point in the history
  • Loading branch information
gperciva committed Jan 13, 2024
1 parent 0ebc966 commit c56174a
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
2 changes: 1 addition & 1 deletion tests/fork_func/check.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ int check_exit(void);

/**
* check_exec(void):
* Check that fork_func() works with exec().
* Check that fork_func() works with an exec* function.
*/
int check_exec(void);

Expand Down
10 changes: 8 additions & 2 deletions tests/fork_func/check_exec.c
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ func_exec(void * cookie)

(void)cookie; /* UNUSED */

/* Execute the "true" binary found in the $PATH. */
if (execlp("true", "true", NULL))
warnp("execvp");

Expand All @@ -20,14 +21,19 @@ func_exec(void * cookie)

/**
* check_exec(void):
* Check that fork_func() works with exec().
* Check that fork_func() works with an exec* function.
*/
int
check_exec(void)
{
pid_t pid;

/* Fork. */
if (fork_func(func_exec, NULL) == -1)
if ((pid = fork_func(func_exec, NULL) == -1))
goto err0;

/* Check that it didn't fail. */
if (fork_func_wait(pid) != 0)
goto err0;

/* Success! */
Expand Down

0 comments on commit c56174a

Please sign in to comment.