diff options
Diffstat (limited to 'testModule/systemd-preserve-process-marker.c')
| -rw-r--r-- | testModule/systemd-preserve-process-marker.c | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/testModule/systemd-preserve-process-marker.c b/testModule/systemd-preserve-process-marker.c index 2525bc5f..8f0fc108 100644 --- a/testModule/systemd-preserve-process-marker.c +++ b/testModule/systemd-preserve-process-marker.c @@ -17,13 +17,15 @@ void print_array(int argc, char *argv[]) { } int main(int argc, char *argv[]) { int count; - char **copy = malloc(sizeof(char *) * (argc-1)); + // Last item acts as null pointer. + char **copy = calloc(sizeof(char *), argc); + // Slice first given command line argument. for (count = 0; count < argc - 1; count++) copy[count] = strdup(argv[count + 1]); // Adding systemd indicator to preserve wrapped process during changing // root filesystem. We mark wrapper and child process. - copy[0][0] = '@'; argv[0][0] = '@'; + copy[0][0] = '@'; if (-1 == execvp(argv[1], copy)) { perror("Executing child process failed."); return -1; |
