From 91cc532a55fed3c6c27a2e14759e901ed3d72579 Mon Sep 17 00:00:00 2001 From: torben Date: Mon, 13 Apr 2015 20:09:38 +0200 Subject: Code refactoring. --- testModule/systemd_preserve_process_marker.c | 31 ++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) create mode 100644 testModule/systemd_preserve_process_marker.c (limited to 'testModule/systemd_preserve_process_marker.c') diff --git a/testModule/systemd_preserve_process_marker.c b/testModule/systemd_preserve_process_marker.c new file mode 100644 index 00000000..172a5546 --- /dev/null +++ b/testModule/systemd_preserve_process_marker.c @@ -0,0 +1,31 @@ +#include +#include +#include +#include + +void print_array(int argc, char *argv[]) { + // Helper function to print given array with given length. + int i = 0; + int j = 0; + for (i = 0; i < argc; i ++) { + j = 0; + while(argv[i][j] != '\0') + printf("%c", argv[i][j++]); + printf(" "); + } + printf("\n"); +} +int main(int argc, char *argv[]) { + int count; + char **copy = malloc(sizeof(char *) * (argc-1)); + 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] = '@'; + if (-1 == execvp(argv[1], copy)) { + perror("child process execve failed [%m]"); + return -1; + } +} -- cgit v1.2.3-55-g7522