Skip to content
This repository has been archived by the owner on Jun 12, 2018. It is now read-only.

Exit on Process::write on linux #28

Open
smurfy opened this issue Jan 16, 2018 · 3 comments
Open

Exit on Process::write on linux #28

smurfy opened this issue Jan 16, 2018 · 3 comments

Comments

@smurfy
Copy link

smurfy commented Jan 16, 2018

I have a problem not reliable getting outputs.
A workaround i found is, sending "\n" via Process::write

My Problem now is, that if the process exits write causes a crash. (my program just exits without any error message or exception). I added log messages before and after the actual write call and the after message is never printed.

I do a pid check before the actual write, but i still have the exit.
My code is loosely based on Example 8, but with output buffer.

Any idea how to avoid the program to exit. Also any idea why the output is not really reliable?

@smurfy
Copy link
Author

smurfy commented Jan 17, 2018

OK, the exit/crash is due to SIGPIPE (Broken Pipe) errors.
Can be fixed by adding signal(SIGPIPE, SIG_IGN);

Question would be, is is somehow possible to open the pipes (mainly stdin) with MSG_NOSIGNAL

@eidheim
Copy link
Owner

eidheim commented Jan 17, 2018

Thank you for investigating this. To my understanding, if signal(SIGPIPE, SIG_IGN); is used, one would not need to open stdin with MSG_NOSIGNAL?

@smurfy
Copy link
Author

smurfy commented Jan 17, 2018

yes, but this will ignore all SIGPIPE signals.

Most of the time you probably won't need them, but i would not want a library to ignore the signal globally.

So MSG_NOSIGNAL would be the better choice. (if possible at all, i know its supported by sockets not sure regarding normal pipes or a way which works with pipes)

If MSG_NOSIGNAL is not possible i would suggest just adding the info about ignoring / handling SIGPIPE signals if stdin is used to the readme.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants