Permalink
Browse files

Handle EAGAIN in write()

  • Loading branch information...
1 parent 994b140 commit 7517e6371b537d5db29715dccc772d30e07a18d1 Igor Sukhih committed Oct 10, 2005
Showing with 11 additions and 3 deletions.
  1. +11 −3 src/enter.c
View
@@ -105,9 +105,11 @@ static int stdredir(int rdfd, int wrfd)
lenremain = lenr;
p = buf;
while (lentotal < lenr) {
- if ((lenw = write(wrfd, p, lenremain)) < 0) {
- if (errno != EINTR)
- return -1;
+ while ((lenw = write(wrfd, p, lenremain)) < 0)
+ if (errno != EINTR && errno != EAGAIN)
+ break;
+ if (lenw < 0) {
+ return -1;
} else {
lentotal += lenw;
lenremain -= lenw;
@@ -182,6 +184,10 @@ int do_enter(vps_handler *h, envid_t veid, char *root)
act.sa_handler = child_handler;
sigaction(SIGCHLD, &act, NULL);
+ act.sa_handler = SIG_IGN;
+ act.sa_flags = 0;
+ sigaction(SIGPIPE, &act, NULL);
+
if ((pid = fork()) < 0) {
logger(0, errno, "Unable to fork");
ret = VZ_RESOURCE_ERROR;
@@ -262,6 +268,8 @@ int do_enter(vps_handler *h, envid_t veid, char *root)
while ((waitpid(pid, &status, 0)) == -1)
if (errno != EINTR)
break;
+ if (WIFSIGNALED(status))
+ logger(0, 0, "got signal %d", WTERMSIG(status));
if (!ret)
raw_off();
close(in[1]); close(out[0]);

0 comments on commit 7517e63

Please sign in to comment.