Use SOCK_STREAM for socketpair, not SOCK_DGRAM so we get consistent

semantics when the other end closes.  This should make the conversion
to poll() less problematic.
This commit is contained in:
Todd C. Miller
2013-10-12 05:39:02 -06:00
parent a6b4f41103
commit ff18c65862
2 changed files with 24 additions and 25 deletions

View File

@@ -1170,11 +1170,16 @@ exec_monitor(struct command_details *details, int backchannel)
/* read command from backchannel, should be a signal */
n = recv(backchannel, &cstmp, sizeof(cstmp), 0);
if (n == -1) {
if (errno == EINTR)
continue;
warning(_("error reading from socketpair"));
goto done;
if (n != sizeof(cstmp)) {
if (n == -1) {
if (errno == EINTR)
continue;
warning(_("error reading from socketpair"));
goto done;
} else {
/* /* short read or EOF, parent process died? */
goto done;
}
}
if (cstmp.type != CMD_SIGNO) {
warningx(_("unexpected reply type on backchannel: %d"),