Always treat stderr as a stream

Using exact reads for processes running the event loop broke stderr.
This commit is contained in:
Michael Santos
2014-03-29 12:33:10 -04:00
parent f1ff3469a1
commit 8600ae82f0
2 changed files with 11 additions and 3 deletions

View File

@@ -331,7 +331,8 @@ alcove_child_stdio(int fdin, alcove_child_t *c, u_int16_t type)
*
* Otherwise, read in the length header and do an exact read.
*/
if (c->fdctl == ALCOVE_CHILD_EXEC)
if ( (c->fdctl == ALCOVE_CHILD_EXEC)
|| type == ALCOVE_MSG_STDERR)
read_len = MAXMSGLEN;
n = read(fdin, buf, read_len);
@@ -343,7 +344,8 @@ alcove_child_stdio(int fdin, alcove_child_t *c, u_int16_t type)
return -1;
}
if (c->fdctl != ALCOVE_CHILD_EXEC) {
if ( (c->fdctl != ALCOVE_CHILD_EXEC)
&& (type != ALCOVE_MSG_STDERR)) {
n = buf[0] << 8 | buf[1];
if (alcove_read(fdin, buf+2, n) != n)

View File

@@ -123,13 +123,19 @@ setopt({_, Port, _Child}) ->
Opt2 = alcove:getopt(Port, [], maxforkdepth),
Opt3 = alcove:getopt(Port, [Fork], maxforkdepth),
Reply = alcove:fork(Port, [Fork]),
ok = alcove:setopt(Port, [Fork], verbose, 2),
Fork = alcove:getpid(Port, [Fork]),
Stderr = alcove:stderr(Port, [Fork]),
alcove:kill(Port, Fork, 9),
[
?_assertEqual(0, Opt1),
?_assertNotEqual(0, Opt2),
?_assertEqual(0, Opt3),
?_assertEqual({error,eagain}, Reply)
?_assertEqual({error,eagain}, Reply),
?_assertNotEqual(false, Stderr)
].
sethostname({{unix,linux}, Port, Child}) ->