On Fri, Apr 15, 2011 at 1:03 PM, Eli Zaretskii <e...@gnu.org> wrote: > Can Make be invoked with its stdout closed by the parent process? If > it is, will this still work?
I've tried to code it such that if anything goes wrong setting up the sync, of which a closed stdout would be one example, it prints a message and continues on without the sync feature but does not fail the build. Such corner cases have not been tested much. >> + memset(&fl, 0, sizeof(fl)); >> + fl.l_type = F_WRLCK; >> + fl.l_whence = SEEK_SET; >> + fl.l_pid = getpid(); >> + fl.l_start = fl.l_len = 0; >> + if (fcntl(syncfd, F_SETLKW, &fl) == -1) >> + perror("fcntl"); > > As discussed, please factor this out into a separate function. As soon as things settle down. >> + if (c->tempout) >> + while ((nread = fread(buffer, 1, sizeof(buffer), c->tempout)) > 0) >> + write(fileno(stdout), buffer, nread); > > Are we sure c->tempout will be zeroed out by initialization? They're explicitly initialized: + child->tempout = child->temperr = NULL; >> + if (c->tempout) >> + fclose(c->tempout); >> + if (c->temperr) >> + fclose(c->temperr); > > Should we assign NULL to these once they are closed? Yes. I'm working on a new version which replaces these with descriptors anyway. Same principal applies though. David _______________________________________________ Bug-make mailing list Bug-make@gnu.org http://lists.gnu.org/mailman/listinfo/bug-make