Skip to content

Commit

Permalink
Add error checking and proper return value to run_cmd()
Browse files Browse the repository at this point in the history
  • Loading branch information
domsson committed Oct 4, 2020
1 parent ad748df commit 93b3a15
Showing 1 changed file with 13 additions and 3 deletions.
16 changes: 13 additions & 3 deletions src/succade.c
Original file line number Diff line number Diff line change
Expand Up @@ -814,15 +814,25 @@ static size_t create_sparks(state_s *state)

/*
* Run a command in a 'fire and forget' manner. Does not invoke a shell,
* hence no fancy stuff like pipes can be used with this.
* hence no shell built-in functionality can be used in the command.
* Returns 0 on success, -1 on error.
*/
int run_cmd(const char *cmd)
{
kita_child_s *child = kita_child_new(cmd, 0, 0, 0);
kita_child_open(child); // runs the child via fork/execvp
if (child == NULL)
{
return -1;
}

if (kita_child_open(child) == -1) // runs the child via fork/execvp
{
return -1;
}

kita_child_close(child); // does not stop the child, just closes com channels
kita_child_free(&child);
return 1; // TODO
return 0;
}

/*
Expand Down

0 comments on commit 93b3a15

Please sign in to comment.