* 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
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.
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
sysvinit (2.88dsf) UNRELEASED; urgency=low
"HOME=/",
"PATH=/bin:/usr/bin:/sbin:/usr/sbin",
"TERM=dumb",
"HOME=/",
"PATH=/bin:/usr/bin:/sbin:/usr/sbin",
"TERM=dumb",
sa.sa_handler = alrm_handler;
sigaction(SIGALRM, &sa, NULL);
got_alrm = 0;
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;