Ask Your Question
0

SIGPIPE Conflict and Unmasking

asked 2015-04-05 23:42:50 -0500

ntd gravatar image

I am trying to call roscpp within another program that uses SIGPIPE. ROS is blocking this (in https://github.com/ros/ros_comm/blob/... ) and this breaks things.

Why is SIGPIPE ignored here? Presumably, this would be to prevent the default handler from terminating the process when a socket is disconnected.

My current workaround is to unmask SIGPIPE via sigprocmask() after the ROS libraries are loaded. This seems to be working fine in that I can communicate via ROS and the rest of the program can use SIGPIPE as it needs to. Are there any potential subtle errors that could arise from this?

Ideally, it seems that there should be an option to prevent roscpp from initially blocking SIGPIPE rather than it unconditionally modifying the process-global state.

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
0

answered 2015-04-17 10:49:37 -0500

gerkey gravatar image

That code is pretty old, so it's hard to know, but I would guess that the purpose is to avoid the chance of receiving a SIGPIPE due to something bad happening to a socket, which could happen pretty often, given how many sockets we might be using and the variety of network conditions we're running in. As you point out, the default behavior for SIGPIPE is to terminate the program, so if we expect to receive it, then we either need to ignore it or catch it.

I don't see a problem with your workaround of unmasking SIGPIPE and catching it yourself. But you should know that you might get SIGPIPEs that are generated due to roscpp's sockets, as opposed to your own resources.

edit flag offensive delete link more

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

2 followers

Stats

Asked: 2015-04-05 23:42:50 -0500

Seen: 188 times

Last updated: Apr 05 '15