--- loader/init.c | 24 ++++++++++++++++++++---- loader/loader.c | 34 +++++++++++++++++++++++++++------- 2 files changed, 47 insertions(+), 11 deletions(-) diff --git a/loader/init.c b/loader/init.c index b04d872..0a28c71 100644 --- a/loader/init.c +++ b/loader/init.c @@ -609,7 +609,11 @@ int main(int argc, char **argv) { struct termios cmode, mode; int cfd; - cfd = open("/dev/console", O_RDONLY); + if ((cfd = open("/dev/console", O_RDONLY)) == -1) { + printf("failed to open /dev/console\n"); + fatal_error(1); + } + tcgetattr(cfd,&orig_cmode); orig_flags = fcntl(cfd, F_GETFL); close(cfd); @@ -617,7 +621,11 @@ int main(int argc, char **argv) { cmode = orig_cmode; cmode.c_lflag &= (~ECHO); - cfd = open("/dev/console", O_WRONLY); + if ((cfd = open("/dev/console", O_WRONLY)) == -1) { + printf("failed to open /dev/console\n"); + fatal_error(1); + } + tcsetattr(cfd,TCSANOW,&cmode); close(cfd); @@ -646,7 +654,11 @@ int main(int argc, char **argv) { close(fd); } - cfd = open("/dev/console", O_WRONLY); + if ((cfd = open("/dev/console", O_WRONLY)) == -1) { + printf("failed to open /dev/console\n"); + fatal_error(1); + } + tcsetattr(cfd,TCSANOW,&orig_cmode); close(cfd); @@ -845,7 +857,11 @@ int main(int argc, char **argv) { (WIFEXITED(waitStatus) && WEXITSTATUS(waitStatus))) { /* Restore terminal */ - cfd = open("/dev/console", O_RDONLY); + if ((cfd = open("/dev/console", O_RDONLY)) == -1) { + printf("failed to open /dev/console\n"); + fatal_error(1); + } + tcsetattr(cfd, TCSANOW, &orig_cmode); fcntl(cfd, F_SETFL, orig_flags); close(cfd); diff --git a/loader/loader.c b/loader/loader.c index 177d8a3..dd1e0f8 100644 --- a/loader/loader.c +++ b/loader/loader.c @@ -196,8 +196,9 @@ void doGdbserver(struct loaderData_s *loaderData) { } checked_asprintf(&pid, "%d", loaderPid); + child = fork(); - if (!(child = fork())) { + if (child == 0) { logMessage(INFO, "starting gdbserver: %s %s %s %s", "/usr/bin/gdbserver", "--attach", loaderData->gdbServer, pid); @@ -218,6 +219,9 @@ void doGdbserver(struct loaderData_s *loaderData) { logMessage(ERROR, "error running gdbserver: %m"); _exit(1); + } else if (child == -1) { + logMessage(ERROR, "%s (%d): %m", __func__, __LINE__); + newtResume(); } } } @@ -382,7 +386,9 @@ static void spawnShell(void) { return; } - if (!(pid = fork())) { + pid = fork(); + + if (pid == 0) { int fd; fd = open("/dev/tty2", O_RDWR|O_NOCTTY); @@ -421,6 +427,8 @@ static void spawnShell(void) { logMessage(CRITICAL, "exec of /bin/sh failed: %m"); exit(1); } + } else if (pid == -1) { + logMessage(ERROR, "%s (%d): %m", __func__, __LINE__); } return; @@ -2230,9 +2238,12 @@ int main(int argc, char ** argv) { if (!FL_NOPROBE(flags)) detectHardware(USB_DETECT_DELAY); /* HAL daemon */ - if (fork() == 0) { + pid = fork(); + if (pid == 0) { execl("/sbin/hald", "/sbin/hald", "--use-syslog", NULL); doExit(1); + } else if (pid == -1) { + logMessage(ERROR, "%s (%d): %m", __func__, __LINE__); } /* Disable all network interfaces in NetworkManager by default */ @@ -2275,7 +2286,9 @@ int main(int argc, char ** argv) { } if (FL_EARLY_NETWORKING(flags)) { - kickstartNetworkUp(&loaderData, &iface); + if (kickstartNetworkUp(&loaderData, &iface)) { + logMessage(ERROR, "failed to bring up early networking device"); + } } if (FL_TELNETD(flags)) @@ -2533,12 +2546,15 @@ int main(int argc, char ** argv) { } printf(fmt, VERSION, getProductName()); - if (!(pid = fork())) { + pid = fork(); + if (pid == 0) { /* This is where the Anaconda python process is started. */ if (execv(anacondaArgs[0], anacondaArgs) == -1) { fprintf(stderr,"exec of anaconda failed: %m\n"); doExit(1); } + } else if (pid == -1) { + logMessage(ERROR, "%s (%d): %m", __func__, __LINE__); } /* Create a new process group that we can easily kill off later. */ @@ -2561,15 +2577,19 @@ int main(int argc, char ** argv) { } if ((rc == 0) && (FL_POWEROFF(flags) || FL_HALT(flags))) { - if (!(pid = fork())) { + pid = fork(); + if (pid == 0) { char * cmd = (FL_POWEROFF(flags) ? strdup("/sbin/poweroff") : strdup("/sbin/halt")); if (execl(cmd, cmd, NULL) == -1) { fprintf(stderr, "exec of poweroff failed: %m\n"); doExit(1); } + } else if (pid == -1) { + logMessage(ERROR, "%s (%d): %m", __func__, __LINE__); + } else { + waitpid(pid, &status, 0); } - waitpid(pid, &status, 0); } stop_fw_loader(&loaderData); -- 1.7.1 _______________________________________________ Anaconda-devel-list mailing list Anaconda-devel-list@xxxxxxxxxx https://www.redhat.com/mailman/listinfo/anaconda-devel-list