The signal sigpipe needing attention in the programming of Linux Network

Source: Internet
Author: User

In the commissioning of CS, the S-end loop, the C-terminal loop, the S-end after an unexpected crash, the C-terminal automatic exit, terminal hint Sigpipe cause C end exit. Man 7 signal:

Sigpipe          broken pipe:write to pipe with no readers

Sigpipe occurs when: Write a pipe that is not read, the default action is to terminate the program. Man 2 write:

Epipe is is    closed.                This happens the writing process would also receive  a  sig-              PIPE  signal.   return  is if the                this signal.)

The write error code epipe occurs when the read end of the write FD corresponding pipe or socket pair end is closed. The return value of the write operation is only received when the program catches, blocks, and ignores this signal because sigpipe terminates the program by default.

There is a detail, using GDB single-step debugging C-side, before the start of write, manually terminate the S-side, C-side received the fin section of S, and reply to the ack,c end is in the close_wait state, at this time, the C end of the write operation returned the value is normal, the socket state does not exist, Wireshark Grab bag will find an RST package, indicating that the socket connection has been reset, write again, will receive the sigpipe immediately. The exact writing of a socket that has received the RST sub-section will produce sigpipe.

Signals to be aware of in Linux network programming sigpipe

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.