Don't choke if /etc/profile is not available
authorEric Andersen <andersen@codepoet.org>
Tue, 26 Jun 2001 23:00:21 +0000 (23:00 -0000)
committerEric Andersen <andersen@codepoet.org>
Tue, 26 Jun 2001 23:00:21 +0000 (23:00 -0000)
hush.c
shell/hush.c

diff --git a/hush.c b/hush.c
index 859353dcf5fc4ddca1bf08700659f80ceb7a7d0e..f70074f14264f7438af13d61c65cb33698d5efd3 100644 (file)
--- a/hush.c
+++ b/hush.c
@@ -2556,9 +2556,7 @@ static void setup_job_control()
 
        /* Put ourselves in our own process group.  */
        shell_pgrp = getpid ();
-       if (setpgid (shell_pgrp, shell_pgrp) < 0) {
-               perror_msg_and_die("Couldn't put the shell in its own process group");
-       }
+       setpgid (shell_pgrp, shell_pgrp);
 
        /* Grab control of the terminal.  */
        tcsetpgrp(shell_terminal, shell_pgrp);
@@ -2607,11 +2605,12 @@ int shell_main(int argc, char **argv)
 
        if (argv[0] && argv[0][0] == '-') {
                debug_printf("\nsourcing /etc/profile\n");
-               input = xfopen("/etc/profile", "r");
-               mark_open(fileno(input));
-               parse_file_outer(input);
-               mark_closed(fileno(input));
-               fclose(input);
+               if ((input = fopen("/etc/profile", "r")) != NULL) {
+                       mark_open(fileno(input));
+                       parse_file_outer(input);
+                       mark_closed(fileno(input));
+                       fclose(input);
+               }
        }
        input=stdin;
        
index 859353dcf5fc4ddca1bf08700659f80ceb7a7d0e..f70074f14264f7438af13d61c65cb33698d5efd3 100644 (file)
@@ -2556,9 +2556,7 @@ static void setup_job_control()
 
        /* Put ourselves in our own process group.  */
        shell_pgrp = getpid ();
-       if (setpgid (shell_pgrp, shell_pgrp) < 0) {
-               perror_msg_and_die("Couldn't put the shell in its own process group");
-       }
+       setpgid (shell_pgrp, shell_pgrp);
 
        /* Grab control of the terminal.  */
        tcsetpgrp(shell_terminal, shell_pgrp);
@@ -2607,11 +2605,12 @@ int shell_main(int argc, char **argv)
 
        if (argv[0] && argv[0][0] == '-') {
                debug_printf("\nsourcing /etc/profile\n");
-               input = xfopen("/etc/profile", "r");
-               mark_open(fileno(input));
-               parse_file_outer(input);
-               mark_closed(fileno(input));
-               fclose(input);
+               if ((input = fopen("/etc/profile", "r")) != NULL) {
+                       mark_open(fileno(input));
+                       parse_file_outer(input);
+                       mark_closed(fileno(input));
+                       fclose(input);
+               }
        }
        input=stdin;