249
269
if (read_proc(&prcs_run, &prcs_blked))
272
/* if we have preload running, we expect I/O not to be a problem */
273
if (ispreload != NoPreload)
252
276
newpar = (par*numcpu) - prcs_run + 1; /* +1 for startpar its self */
253
277
newpar -= (int)(((double)prcs_blked)*iorate); /* I/O load reduction */
256
fprintf(stderr, "checksystem par=%d newpar=%d (prcs_run=%u) %ld\n", par, newpar, prcs_run, time(0));
280
fprintf(stderr, "checksystem par=%d newpar=%d (prcs_run=%lu) %ld\n", par, newpar, prcs_run, time(0));
272
296
return checksystem(par, start, false);
299
#define SOCK_PATH "/dev/shm/preload_sock"
302
static int checkdevpts(void)
304
/* /dev/pts is always mounted */
276
309
* Based on __posix_openpt() from glibc. Reimplemented here to work
277
310
* around the problem with getpt() failing for the entire process life
436
if (!strcmp(arg, "start"))
440
struct sockaddr_un remote;
443
s = socket(AF_UNIX, SOCK_STREAM, 0);
446
memset(&remote, 0, sizeof(struct sockaddr_un));
447
remote.sun_family = AF_UNIX;
448
strcpy(remote.sun_path, SOCK_PATH);
449
len = strlen(remote.sun_path) + sizeof(remote.sun_family);
451
t = connect(s, (struct sockaddr *)&remote, len);
454
if (ispreload != Preload)
455
kill(parent, SIGUSR1);
456
send(s, p->name, strlen(p->name), 0);
457
recv(s, str, 100, 0);
459
else if ( ispreload == Unknown)
462
* if we connected to preload once, we know it ran.
463
* In case we can't connect to it later, it means it did
464
* its job and we can guess I/O is no longer a problem.
466
kill(parent, SIGUSR2);
470
* if we use preload, we fork again to make bootcharts easier to read.
471
* The reason is that the name of the init script will otherwise be used
472
* when in reality the above code waited for preload. If we fork away
473
* before the exec, the waiting code will be folded into startpar
478
int ret = waitpid(child, &status, 0);
481
exit(WEXITSTATUS(status));
404
489
snprintf(path, sizeof(path), "/etc/init.d/%s", p->name);
405
execlp(path, path, arg, (char *)0);
490
execlp(path, p->arg0, arg, (char *)0);
408
execlp(p->name, p->name, arg, (char *)0);
493
execlp(p->name, p->arg0, arg, (char *)0);
410
execlp(p->name, p->name, (char *)0);
495
execlp(p->name, p->arg0, (char *)0);
415
int run_single(char *prg, int spl)
500
int run_single(const char *prg, const char *arg0, int spl)
441
526
snprintf(path, sizeof(path), "/etc/init.d/%s", prg);
442
execlp(path, path, arg, (char *)0);
527
execlp(path, arg0 ? arg0 : path, arg, (char *)0);
445
execlp(prg, prg, arg, (char *)0);
530
execlp(prg, arg0 ? arg0 : prg, arg, (char *)0);
447
execlp(prg, prg, (char *)0);
532
execlp(prg, arg0 ? arg0 : prg, (char *)0);
614
699
char *run_level = getenv("RUNLEVEL");
615
700
char *splashopt = 0;
702
(void)signal(SIGUSR1, sighandler_preload);
703
(void)signal(SIGUSR2, sighandler_nopreload);
617
705
(void)signal(SIGCHLD, SIG_DFL);
618
706
numcpu = sysconf(_SC_NPROCESSORS_ONLN);
619
707
myname = argv[0];
768
856
if ((*nodevec = pickup_task()))
770
*resvec = run_single((*nodevec)->name, calcsplash(0, 1, splashopt));
858
*resvec = run_single((*nodevec)->name, (*nodevec)->arg0, calcsplash(0, 1, splashopt));
771
859
finish_task(*nodevec);
774
*resvec = run_single(*argv, calcsplash(0, 1, splashopt));
862
*resvec = run_single(*argv, *argv, calcsplash(0, 1, splashopt));
878
966
if (nodevec[num]->interactive)
879
967
interactive_task = p;
880
968
p->name = nodevec[num]->name;
969
p->arg0 = nodevec[num]->arg0 ? nodevec[num]->arg0 : nodevec[num]->name;
883
972
p->name = *argv++;
884
975
p->splashadd = calcsplash(num, argc, splashopt);
886
if (!devpts) /* no /dev/pts, treat as interactive */
887
interactive_task = p;
888
977
if (interactive_task)
889
978
continue; /* don't start this here */
981
interactive_task = p; /* no /dev/pts, treat as interactive */