SIGPIPE and EPIPE


 
Thread Tools Search this Thread
Top Forums Programming SIGPIPE and EPIPE
# 1  
Old 11-16-2011
SIGPIPE and EPIPE

When a write() writes on a broken pipe, with no readers, it generates a SIGPIPE signal and the process exits.

When the write() returns -1 and errno is EPIPE?
Do I have an handler for SIGPIPE, or can I ignore it?
# 2  
Old 11-16-2011
SIGPIPE is for situations like this:

Code:
grep "pattern" < reallyhugefile | head

grep might print millions of lines, but head only reads 10 then quits. Once head closes the read-end and quits, grep gets SIGPIPE, which kills it, forcing it to quit early instead of processing the entire file uselessly.

If you don't want your program to be killed, handle or block SIGPIPE yourself. You will start getting write-errors with errno set to EPIPE instead.
# 3  
Old 11-22-2011
SIGPIPE the reason is close(pipe_fd[0]) when you use write() funciton .

close(pipe_fd[1]) in your child process or parent process, can solve this problem.

If you still want to ignore it. use sigaction() function.
type:
Code:
man sigaction

Login or Register to Ask a Question

Previous Thread | Next Thread

5 More Discussions You Might Find Interesting

1. UNIX for Advanced & Expert Users

Why not SIGPIPE for readers of pipe/FIFO?

Hi This is a exercise question from Unix network programming vol2. Why the SIGPIPE signal is generated only for writers when readers disappear. why not it is generated for readers when writer disappears. I guess, if the writer didn't get any response like the reader gets EOF, it will... (4 Replies)
Discussion started by: kumaran_5555
4 Replies

2. Programming

Catch signal SIGPIPE print errno but it's value equal to 2

catch signal SIGPIPE ,print errno but it's value equal to 2(ENOENT) #define ENOENT 2 /* No such file or directory */ is it should be EPIPE ? #define EPIPE 32 /* Broken pipe */ Thanks ! (7 Replies)
Discussion started by: aobai
7 Replies

3. Programming

Reliable management of signal SIGPIPE and SIGTERM

I' m note very expert in the reliable manage of signal... but in my server I must manage SIGPIPE for the socket and SIGTERM... I've wrote this but there is something wrong... Can someone explain me with some example the reliable management of signal?? This is what I've wrote in the server ... (2 Replies)
Discussion started by: italian_boy
2 Replies

4. Solaris

"lpr.error] Warning: Received SIGPIPE" continuously appearing in logs

On a Solaris 8 print server we're continuously (every 2 minutes or so) getting these messages in the logs: printd: Warning: Received SIGPIPE; continuing I've applied this patch and restarted the printd daemon, but it doesn't help: #109320-22: SunOS 5.8: lp patch Does anyone have any idea what... (4 Replies)
Discussion started by: aussieos
4 Replies

5. AIX

auditing fails with SIGPIPE signal on 1/4 hour

Hi folks, Can anyone assist with pointers for the following snag? We have custom method (IBM-supplied) for running the audit subsystem on 5.1-07 /etc/security/audit objects, events and config have been edited, and the /etc/security/audit/streamcmds contains the following routine; ... (1 Reply)
Discussion started by: reclspeak
1 Replies
Login or Register to Ask a Question