* Set SHELL to /bin/sh in the environmant of shutdown.
authorDr. Werner Fink <werner@suse.de>
Tue, 23 Feb 2010 12:26:26 +0000 (12:26 +0000)
committerDr. Werner Fink <werner@suse.de>
Tue, 23 Feb 2010 12:26:26 +0000 (12:26 +0000)
  * Retry to write out shutdown messages if interrupted.

git-svn-id: svn://svn.sv.gnu.org/sysvinit/sysvinit/trunk@36 456724a4-4300-0410-8514-c89748c515a2

doc/Changelog
src/shutdown.c

index 858471b4e86ecca5bf76bc7060d900f696e4d4b6..e800bea1d9d35f3c8812cb73b371b5aadd22674d 100644 (file)
@@ -9,6 +9,8 @@
     to flush data and send them the ATA standby command.  This should
     avoid data loss on USB sticks and other removable block devices.
   * Flush block devices on halt/reboot if not done by the kernel.
+  * Set SHELL to /bin/sh in the environmant of shutdown.
+  * Retry to write out shutdown messages if interrupted.
 
 sysvinit (2.88dsf) UNRELEASED; urgency=low
 
index 84f99f12ffbd62dcd60860c3b5323aa0d6efe02b..3ec0341992cb65fa52a9865aeeaa8e382e253d02 100644 (file)
@@ -71,6 +71,7 @@ char *clean_env[] = {
        "HOME=/",
        "PATH=/bin:/usr/bin:/sbin:/usr/sbin",
        "TERM=dumb",
+       "SHELL=/bin/sh",
        NULL,
 };
 
@@ -166,22 +167,34 @@ int init_setenv(char *name, char *value)
        sa.sa_handler = alrm_handler;
        sigaction(SIGALRM, &sa, NULL);
        got_alrm = 0;
-        alarm(3);
-        if ((fd = open(INIT_FIFO, O_WRONLY)) >= 0 &&
-            write(fd, &request, sizeof(request)) == sizeof(request)) {
-                close(fd);
-                alarm(0);
-                return 0;
-        }
+       alarm(3);
+       if ((fd = open(INIT_FIFO, O_WRONLY)) >= 0) { &&
+               ssize_t p = 0;
+               size_t s  = sizeof(request);
+               void *ptr = &request;
+               while (s > 0) {
+                       p = write(fd, ptr, s);
+                       if (p < 0) {
+                               if (errno == EINTR || errno == EAGAIN)
+                                       continue;
+                               break;
+                       }
+                       ptr += p;
+                       s -= p;
+               }
+               close(fd);
+               alarm(0);
+               return 0;
+       }
                                                                                 
-        fprintf(stderr, "shutdown: ");
-        if (got_alrm) {
-                fprintf(stderr, "timeout opening/writing control channel %s\n",
-                        INIT_FIFO);
-        } else {
-                perror(INIT_FIFO);
-        }
-        return -1;
+       fprintf(stderr, "shutdown: ");
+       if (got_alrm) {
+               fprintf(stderr, "timeout opening/writing control channel %s\n",
+                       INIT_FIFO);
+       } else {
+               perror(INIT_FIFO);
+       }
+       return -1;
 }