summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDean Jansa <djansa@redhat.com>2005-08-31 19:09:38 +0000
committerDean Jansa <djansa@redhat.com>2005-08-31 19:09:38 +0000
commit4ac88fc3498eca53a4c419412cf18a8d102daa41 (patch)
treeb55fec3f973f0151ee9fcc115dfe74d743c51707
parent6ec1970b75504d015116fc6bfe2133e9ee4908cd (diff)
downloadqarsh-4ac88fc3498eca53a4c419412cf18a8d102daa41.tar.gz
qarsh-4ac88fc3498eca53a4c419412cf18a8d102daa41.tar.xz
qarsh-4ac88fc3498eca53a4c419412cf18a8d102daa41.zip
Pull signal handleing out of the error case of a pselect return.
We want to handle the child_exitted flag each time we come out of the pselect.
-rw-r--r--qarsh/qarshd.c27
1 files changed, 16 insertions, 11 deletions
diff --git a/qarsh/qarshd.c b/qarsh/qarshd.c
index f7e5dd6..3eb9182 100644
--- a/qarsh/qarshd.c
+++ b/qarsh/qarshd.c
@@ -85,6 +85,7 @@ run_cmd(const char *cmd, int p_in, int p_out, int p_err)
dup2(new_err, fileno(stderr));
execlp("sh", "sh", "-c", cmd, NULL);
+ printf("exec of %s failed: %d, %s\n", cmd, errno, strerror(errno));
exit(127);
}
return pid;
@@ -113,21 +114,25 @@ handle_packets(int infd)
for (;;) {
FD_SET(infd, &rfds);
- timeout.tv_sec = 5;
+ timeout.tv_sec = 3;
+
+ nfd = pselect(infd+1, &rfds, NULL, NULL, &timeout, &orig_sigmask);
+
+ if (child_exitted) {
+ waitpid(child_pid, &child_status, 0);
+ child_exitted--;
+ rp = make_qp_cmdexit(child_pid, child_status);
+ send_packet(fileno(stdout), rp);
+ qpfree(rp);
+ }
- nfd = pselect(infd+1, &rfds, NULL, NULL, &timeout,
- &orig_sigmask);
if (nfd < 0) {
if (errno == EINTR) {
- /* Handle signals here */
- if (child_exitted) {
- waitpid(child_pid, &child_status, 0);
- rp = make_qp_cmdexit(child_pid, child_status);
- send_packet(fileno(stdout), rp);
- qpfree(rp);
- }
+ /* signals handled above here */
+ continue;
} else {
- syslog(LOG_ERR, "select errno %d, %s\n", errno, strerror(errno));
+ syslog(LOG_ERR, "select errno %d, %s\n",
+ errno, strerror(errno));
}
} else if (nfd > 0) {
qp = recv_packet(infd);