fix: Close fds in child processes#914
Conversation
|
Since we dup pipe fds to stdio fds with "self-pipe trick" thing is removed here; I honestly don't see how engines are supposed to use those pipes for signal processing. Can you explain about its use case, I'm curious about it. EDIT 1: |
Okay so the current implementation uses a poll + read, the timeout on the poll is the remaining thinking time of the engine, meaning if poll times out, the engines time ran out and we return, otherwise we know there is data to be read meaning we can read from the pipe. Meaning in your implementation CTRL + C sent to fastchess will take longer, growing with the engines TC. This is not ideal. Does your change actually lead to child processes being killed when fastchess receives SIGKILL, I assume so right ? Maybe we don't need the self pipe trick and instead poll every few cycles (TBD) and implement a timeout in some other cheap way. |
|
didn't mean to close |
Thank you for the explanation. Although I still think the comment is somewhat misplaced, because both write/read a NULL byte is done in fastchess (if this is what you mean by "write some dummy data") and completely unrelated to child processes' file descriptors.
If I understand correctly (as above), my implementation will never affect to how fastchess manages Ctrl+C signals.
Yes. But I'd like to reiterate that child processes are not "killed". They terminate once fastchess is killed, because the pipes are closed and do
{
if (cli.argc == 1
&& !getline(std::cin, cmd)) // Wait for an input or an end-of-file (EOF) indication
cmd = "quit"; |
|
oh i think i might have misunderstood the actual behavior.. the comment ( |
|
Oh macOS doesn't have |
|
you can probably use the fcntl way instead everywhere instead of relying on pipe2 |
7ad7274 to
506eaa7
Compare
|
Should be fixed by now. |
|
Haven't tested it but I think this looks good |
|
thanks again got around to finally test this and it works splendid |
|
okay just for documentation purposes.. |
No description provided.