aboutsummaryrefslogtreecommitdiff
path: root/init.c
diff options
context:
space:
mode:
Diffstat (limited to 'init.c')
-rw-r--r--init.c24
1 files changed, 22 insertions, 2 deletions
diff --git a/init.c b/init.c
index 907916537..f327a52af 100644
--- a/init.c
+++ b/init.c
@@ -45,7 +45,7 @@
45#include <sys/reboot.h> 45#include <sys/reboot.h>
46#include <sys/sysinfo.h> /* For check_free_memory() */ 46#include <sys/sysinfo.h> /* For check_free_memory() */
47#ifdef BB_SYSLOGD 47#ifdef BB_SYSLOGD
48#include <sys/syslog.h> 48# include <sys/syslog.h>
49#endif 49#endif
50#include <sys/sysmacros.h> 50#include <sys/sysmacros.h>
51#include <sys/types.h> 51#include <sys/types.h>
@@ -54,6 +54,15 @@
54#include <termios.h> 54#include <termios.h>
55#include <unistd.h> 55#include <unistd.h>
56 56
57
58/*
59 * When CORE_ENABLE_FLAG_FILE exists, setrlimit is called before
60 * process is spawned to set corelimit to unlimited.
61 */
62#define CORE_ENABLE_FLAG_FILE "/.init_enable_core"
63#include <sys/resource.h>
64#include <sys/time.h>
65
57#ifndef KERNEL_VERSION 66#ifndef KERNEL_VERSION
58#define KERNEL_VERSION(a,b,c) (((a) << 16) + ((b) << 8) + (c)) 67#define KERNEL_VERSION(a,b,c) (((a) << 16) + ((b) << 8) + (c))
59#endif 68#endif
@@ -406,6 +415,16 @@ static pid_t run(char *command, char *terminal, int get_enter)
406 cmd[i] = NULL; 415 cmd[i] = NULL;
407 } 416 }
408 417
418 {
419 struct stat sb;
420 if (stat (CORE_ENABLE_FLAG_FILE, &sb) == 0) {
421 struct rlimit limit;
422 limit.rlim_cur = RLIM_INFINITY;
423 limit.rlim_max = RLIM_INFINITY;
424 setrlimit(RLIMIT_CORE, &limit);
425 }
426 }
427
409 /* Now run it. The new program will take over this PID, 428 /* Now run it. The new program will take over this PID,
410 * so nothing further in init.c should be run. */ 429 * so nothing further in init.c should be run. */
411 execve(cmd[0], cmd, environment); 430 execve(cmd[0], cmd, environment);
@@ -836,6 +855,7 @@ extern int init_main(int argc, char **argv)
836 close(1); 855 close(1);
837 close(2); 856 close(2);
838 set_term(0); 857 set_term(0);
858 chdir("/");
839 setsid(); 859 setsid();
840 860
841 /* Make sure PATH is set to something sane */ 861 /* Make sure PATH is set to something sane */
@@ -881,7 +901,7 @@ extern int init_main(int argc, char **argv)
881 * of "askfirst" shells */ 901 * of "askfirst" shells */
882 parse_inittab(); 902 parse_inittab();
883 } 903 }
884 904
885 /* Fix up argv[0] to be certain we claim to be init */ 905 /* Fix up argv[0] to be certain we claim to be init */
886 strncpy(argv[0], "init", strlen(argv[0])+1); 906 strncpy(argv[0], "init", strlen(argv[0])+1);
887 if (argc > 1) 907 if (argc > 1)