1

"Program received signal SIGPIPE, Broken pipe." and terminated. I use the following code to open pipes. Correct Code - Non-blocking pipe with popen

As you see, I only read from the pipe. Is it the correct behavior to simple ignore SIGPIPE signal? Why does SIGPIPE appear on read? Maybe I do something wrong? Or maybe I must use other call to execute the third part program and the result?

Community
  • 1
  • 1
abrahab
  • 2,430
  • 9
  • 39
  • 64
  • possible duplicate of [Correct Code - Non-blocking pipe with popen](http://stackoverflow.com/questions/10962044/correct-code-non-blocking-pipe-with-popen) – Jonathan Leffler Jun 10 '12 at 23:59
  • 1
    There isn't enough code available in this question to understand what you're up to. You have an answer to your previous question. You can't get a SIGPIPE from reading on a pipe. You can get SIGPIPE if you write to a pipe that is closed and you don't ignore the signal. If you do ignore the signal, you get an error back from a failed write. – Jonathan Leffler Jun 11 '12 at 00:01
  • Also, it is not clear from anything that's gone before, or in this question, what this question has to do with multi-threading, or daemons. – Jonathan Leffler Jun 11 '12 at 00:38
  • @JonathanLeffler One thread of multithred daemon using the function from the question to open `ffmpeg` and receive `ffmpeg` output. Few times a day I get `SIGPIPE` signal. I use only the `question code` to deal with `popen`. Does not know who can write to it. Maybe the reason at maintenance thread that execution every 300 seconds. Maintenance thread open files ( `ofstream` ) to `write` data to files (serializing). Also there is `std::cout` at the code, but it closed at start `close(STDIN_FILENO); close(STDOUT_FILENO);`. this is what I suspect maybe can course problems. ...That's all... – abrahab Jun 11 '12 at 10:05
  • @JonathanLeffler There are also other threads, but they are sleeping near 99.9% of the time (and when they are working, but `ffmpeg-thread` sleeping - no problems). and it not the duplicate of http://stackoverflow.com/questions/10962044/correct-code-non-blocking-pipe-with-popen because I get `how-to do` in that thread, but now I have the problem with the code. My program begin terminate. sorry for my English, its hard to request for help at not native language. – abrahab Jun 11 '12 at 10:08

0 Answers0