summaryrefslogtreecommitdiffstats
path: root/builder/modules.d/dnbd3-rootfs/binaries/systemd-preserve-process-marker/systemd-preserve-process-marker.c
diff options
context:
space:
mode:
Diffstat (limited to 'builder/modules.d/dnbd3-rootfs/binaries/systemd-preserve-process-marker/systemd-preserve-process-marker.c')
-rw-r--r--builder/modules.d/dnbd3-rootfs/binaries/systemd-preserve-process-marker/systemd-preserve-process-marker.c33
1 files changed, 33 insertions, 0 deletions
diff --git a/builder/modules.d/dnbd3-rootfs/binaries/systemd-preserve-process-marker/systemd-preserve-process-marker.c b/builder/modules.d/dnbd3-rootfs/binaries/systemd-preserve-process-marker/systemd-preserve-process-marker.c
new file mode 100644
index 00000000..8f0fc108
--- /dev/null
+++ b/builder/modules.d/dnbd3-rootfs/binaries/systemd-preserve-process-marker/systemd-preserve-process-marker.c
@@ -0,0 +1,33 @@
+#include <unistd.h>
+#include <stdlib.h>
+#include <string.h>
+#include <stdio.h>
+
+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;
+ // 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.
+ argv[0][0] = '@';
+ copy[0][0] = '@';
+ if (-1 == execvp(argv[1], copy)) {
+ perror("Executing child process failed.");
+ return -1;
+ }
+}