summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorLibravatar smitsohu <smitsohu@gmail.com>2019-02-17 01:37:36 +0100
committerLibravatar GitHub <noreply@github.com>2019-02-17 01:37:36 +0100
commitfcba07c9dca8d50547d60ed85c9ed90ab624d7f9 (patch)
treeb540a26ff62d2c28b134fda0be6e55b38ddb1674 /src
parentmerges (diff)
downloadfirejail-fcba07c9dca8d50547d60ed85c9ed90ab624d7f9.tar.gz
firejail-fcba07c9dca8d50547d60ed85c9ed90ab624d7f9.tar.zst
firejail-fcba07c9dca8d50547d60ed85c9ed90ab624d7f9.zip
shutdown option: give sandbox time to terminate
Diffstat (limited to 'src')
-rw-r--r--src/firejail/shutdown.c12
1 files changed, 6 insertions, 6 deletions
diff --git a/src/firejail/shutdown.c b/src/firejail/shutdown.c
index b70394bc8..afe7109a8 100644
--- a/src/firejail/shutdown.c
+++ b/src/firejail/shutdown.c
@@ -52,15 +52,18 @@ void shut(pid_t pid) {
52 printf("Sending SIGTERM to %u\n", pid); 52 printf("Sending SIGTERM to %u\n", pid);
53 kill(pid, SIGTERM); 53 kill(pid, SIGTERM);
54 54
55 // wait for not more than 10 seconds 55 // wait for not more than about 10 seconds
56 sleep(2); 56 int monsec = 10;
57 int monsec = 8;
58 char *monfile; 57 char *monfile;
59 if (asprintf(&monfile, "/proc/%d/cmdline", pid) == -1) 58 if (asprintf(&monfile, "/proc/%d/cmdline", pid) == -1)
60 errExit("asprintf"); 59 errExit("asprintf");
61 int killdone = 0; 60 int killdone = 0;
62 61
62 usleep(200000) // give sandbox a little head start
63 while (monsec) { 63 while (monsec) {
64 sleep(1);
65 monsec--;
66
64 FILE *fp = fopen(monfile, "r"); 67 FILE *fp = fopen(monfile, "r");
65 if (!fp) { 68 if (!fp) {
66 killdone = 1; 69 killdone = 1;
@@ -75,9 +78,6 @@ void shut(pid_t pid) {
75 killdone = 1; 78 killdone = 1;
76 break; 79 break;
77 } 80 }
78
79 sleep(1);
80 monsec--;
81 } 81 }
82 free(monfile); 82 free(monfile);
83 83