program crashed with EPIPE while without core dump
ProgrammingThis forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
I have questions:
1. Why would the EPIPE occur?
2. How could I fix this problem?
3. Why wouldn't it generate a coredump?(I've set ulimit -c unlimited already)
Edit: After I googled broken pipe, I add signal(SIGPIPE, SIG_IGN); to my program, But my program still crashed by EPIPE (Broken pipe). This is a socket server program.
sigpipe or broken pipe means the communication channel (the pipe itself) has been destroyed. Usually it caused because the other side (the app) died, therefore no app can handle the communication.
So usually either stdin or stdout is redirected to/from another app, but there can be other situation as well.
It will not cause core, it has no meaning in this case. You need to find the other end of the pipe and check that app.
For non-trivial programs (meaning: that handle error conditions on write), add this:
Code:
signal (SIGPIPE, SIG_IGN);
Additionally, this makes EPIPE a possible errno value for a failed write operation, which might need to be considered separately from the other possible errors.
Quote:
Originally Posted by fantasy1215
3. Why wouldn't it generate a coredump?(I've set ulimit -c unlimited already)
If you look at man 7 signal, it says that SIGPIPE results in termination rather than a core dump, presumably since there isn't a real need to perform a backtrace.
Now I've added signal (SIGPIPE, SIG_IGN); already to my program, but the program still gets crashed by EPIPE.
That's a problem with how you handle EPIPE, then. If you want the program to continue, close the descriptor that had the EPIPE and set a flag that indicates that output should be skipped.
Why don't you try to catch the other side? You saw write(7, "V\0 "..., 88) = -1 EPIPE (Broken pipe), so you need to check how it (file descriptor = 7) was opened and why it was dropped (died ??)
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.