[evoke] r1244 committed - * Fix some of the waiting logic, and add some debugging output.

1 view
Skip to first unread message

codesite...@google.com

unread,
Sep 8, 2009, 11:22:14 PM9/8/09
to evoke-...@googlegroups.com
Revision: 1244
Author: heliocentric
Date: Tue Sep 8 20:20:58 2009
Log: * Fix some of the waiting logic, and add some debugging output.


http://code.google.com/p/evoke/source/detail?r=1244

Modified:
/trunk/builder/targets/FreeBSD/share/nsrc/nexusd/nexusd.c

=======================================
--- /trunk/builder/targets/FreeBSD/share/nsrc/nexusd/nexusd.c Sat Sep 5
13:12:05 2009
+++ /trunk/builder/targets/FreeBSD/share/nsrc/nexusd/nexusd.c Tue Sep 8
20:20:58 2009
@@ -143,7 +143,6 @@
close(1);
close(2);

- setctty("/dev/console");
int mib[2], realversion;
size_t length;

@@ -158,6 +157,7 @@
length = sizeof(architecture);
sysctl(mib, 2, &architecture, &length, NULL, 0);

+ setctty("/dev/console");
printf("Initializing FreeBSD/%s: %d (FreeBSD/%%ARCH%%: %d)\n",
architecture, realversion, __FreeBSD_version);


@@ -399,63 +399,57 @@
int * status;
int ret;
pid_t pid;
+
*systartpid = fork();

- switch (*systartpid) {
- case 0:
- if (mode == MULTIUSER) {
- static char * shell = SHPATH;
- static char * nargv[4];
- struct sigaction systart_sa;
- sigemptyset(&systart_sa.sa_mask);
- systart_sa.sa_flags = 0;
- systart_sa.sa_handler = SIG_IGN;
- sigprocmask(SIG_SETMASK, &systart_sa.sa_mask, (sigset_t *) 0);
- setctty("/dev/console");
- nargv[0] = "sh";
- nargv[1] = "/system/share/bin/systart";
- nargv[2] = "autoboot";
- nargv[3] = "0";
- ret = execv(shell, nargv);
- perror(shell);
- exit(5);
- }
- if (mode == SINGLEUSER) {
- static char * shell = TCSHPATH;
- static char * nargv[1];
- struct sigaction systart_sa;
- sigfillset(&systart_sa.sa_mask);
- systart_sa.sa_flags = 0;
- systart_sa.sa_handler = SIG_IGN;
- sigprocmask(SIG_SETMASK, &systart_sa.sa_mask, (sigset_t *) 0);
- setctty("/dev/console");
- nargv[0] = "tcsh";
- ret = execv(shell, nargv);
- perror(shell);
- exit(5);
- }
-
- break;
- case -1:
+ if (*systartpid == 0) {
+ if (mode == MULTIUSER) {
+ static char * shell = SHPATH;
+ static char * nargv[4];
+ struct sigaction systart_sa;
+ sigemptyset(&systart_sa.sa_mask);
+ systart_sa.sa_flags = 0;
+ systart_sa.sa_handler = SIG_IGN;
+ sigprocmask(SIG_SETMASK, &systart_sa.sa_mask, (sigset_t *) 0);
+ nargv[0] = "sh";
+ nargv[1] = "/system/share/bin/systart";
+ nargv[2] = "autoboot";
+ nargv[3] = "0";
+ ret = execv(shell, nargv);
+ perror(shell);
+ exit(5);
+ }
+ if (mode == SINGLEUSER) {
+ static char * shell = TCSHPATH;
+ static char * nargv[1];
+ struct sigaction systart_sa;
+ sigfillset(&systart_sa.sa_mask);
+ systart_sa.sa_flags = 0;
+ systart_sa.sa_handler = SIG_IGN;
+ sigprocmask(SIG_SETMASK, &systart_sa.sa_mask, (sigset_t *) 0);
+ nargv[0] = "tcsh";
+ ret = execv(shell, nargv);
+ perror(shell);
+ exit(5);
+ }
+
+ } else {
+ if (*systartpid == -1) {
printf("Fork error, bailing out before we do any damage\n");
return 4;
- break;
- default:
+ } else {
while (1) {
pid = waitpid(-1, status, 0);
+ printf("pid(%d) returned %d\n", pid, *status);
printf("wait returned %d\n", *status);
- if (*status == 0) {
- sleep(1);
+ if (pid == *systartpid) {
+ perror("systart:");
+ return *status;
} else {
- if (pid == *systartpid) {
- perror("systart:");
- return *status;
- } else {
- sleep(1);
- }
+ printf("pid(%d) returned %d\n", pid, *status);
}
}
- break;
+ }
}
return 1;
}

Reply all
Reply to author
Forward
0 new messages