File tree Expand file tree Collapse file tree 2 files changed +9
-6
lines changed Expand file tree Collapse file tree 2 files changed +9
-6
lines changed Original file line number Diff line number Diff line change 1
1
SHELL =bash
2
- CFLAGS =-std =gnu99 -static -s -Wall -Werror -O3
2
+ CFLAGS_AUTO =-std =gnu99 -static-pie -s -Wall -Werror -O3
3
3
4
4
TEST_PACKAGE_DEPS := build-essential python python-pip procps python-dev python-setuptools
5
5
@@ -8,7 +8,7 @@ VERSION = $(shell cat VERSION)
8
8
9
9
.PHONY : build
10
10
build : VERSION.h
11
- $(CC ) $(CFLAGS ) -o dumb-init dumb-init.c
11
+ $(CC ) $(CFLAGS_AUTO ) $( CFLAGS ) -o dumb-init dumb-init.c
12
12
13
13
VERSION.h : VERSION
14
14
echo ' // THIS FILE IS AUTOMATICALLY GENERATED' > VERSION.h
Original file line number Diff line number Diff line change 15
15
#include <stdio.h>
16
16
#include <stdlib.h>
17
17
#include <string.h>
18
+ #include <spawn.h>
18
19
#include <sys/ioctl.h>
19
20
#include <sys/types.h>
20
21
#include <sys/wait.h>
@@ -292,9 +293,9 @@ int main(int argc, char *argv[]) {
292
293
}
293
294
}
294
295
295
- child_pid = fork ();
296
+ child_pid = vfork ();
296
297
if (child_pid < 0 ) {
297
- PRINTERR ("Unable to fork . Exiting.\n" );
298
+ PRINTERR ("Unable to vfork . Exiting.\n" );
298
299
return 1 ;
299
300
} else if (child_pid == 0 ) {
300
301
/* child */
@@ -306,7 +307,7 @@ int main(int argc, char *argv[]) {
306
307
errno ,
307
308
strerror (errno )
308
309
);
309
- exit (1 );
310
+ _exit (1 );
310
311
}
311
312
312
313
if (ioctl (STDIN_FILENO , TIOCSCTTY , 0 ) == -1 ) {
@@ -322,7 +323,7 @@ int main(int argc, char *argv[]) {
322
323
323
324
// if this point is reached, exec failed, so we should exit nonzero
324
325
PRINTERR ("%s: %s\n" , cmd [0 ], strerror (errno ));
325
- return 2 ;
326
+ _exit ( 2 ) ;
326
327
} else {
327
328
/* parent */
328
329
DEBUG ("Child spawned with PID %d.\n" , child_pid );
@@ -337,4 +338,6 @@ int main(int argc, char *argv[]) {
337
338
handle_signal (signum );
338
339
}
339
340
}
341
+
342
+ return 1 ;
340
343
}
You can’t perform that action at this time.
0 commit comments