Fifo semantics is hard to get right.

Finally: we need to close the command pipe at EOF.
This commit is contained in:
Rafal Wojtczuk 2011-03-16 16:11:05 +01:00
parent 15bab70eae
commit d40fb3a2e1

View File

@ -469,10 +469,11 @@ void handle_trigger_io()
{ {
struct server_header s_hdr; struct server_header s_hdr;
char buf[5]; char buf[5];
int ret;
s_hdr.clid = 0; s_hdr.clid = 0;
s_hdr.len = 0; s_hdr.len = 0;
if (read(trigger_fd, buf, 4) == 4) { if ((ret = read(trigger_fd, buf, 4)) == 4) {
buf[4] = 0; buf[4] = 0;
if (!strcmp(buf, "FCPR")) if (!strcmp(buf, "FCPR"))
s_hdr.clid = QREXEC_EXECUTE_FILE_COPY; s_hdr.clid = QREXEC_EXECUTE_FILE_COPY;
@ -484,11 +485,12 @@ void handle_trigger_io()
} }
} }
// trigger_fd is nonblock - so no need to reopen // trigger_fd is nonblock - so no need to reopen
#if 0 // not really, need to reopen at EOF
close(trigger_fd); if (ret <= 0) {
trigger_fd = close(trigger_fd);
open(QREXEC_AGENT_TRIGGER_PATH, O_RDONLY | O_NONBLOCK); trigger_fd =
#endif open(QREXEC_AGENT_TRIGGER_PATH, O_RDONLY | O_NONBLOCK);
}
} }
int main() int main()