DM: handle SIGPIPE signal

Ignore SIGPIPE signal and handle the error directly when write()
function fails. this will help us to catch the write failure
rather than crashing the UOS.

PS: Observed that when acrnctl stop command was issued from
kata-runtime, UOS was crashing with SIGPIPE signal.

Tracked-On: #3190
Signed-off-by: Vijay Dhanraj <vijay.dhanraj@intel.com>
Acked-by: Yu Wang <yu1.wang@intel.com>
This commit is contained in:
Vijay Dhanraj 2019-05-28 17:52:49 -07:00 committed by wenlingz
parent 19366458f8
commit a4e28213c2

View File

@ -785,6 +785,13 @@ main(int argc, char *argv[])
fprintf(stderr, "cannot register handler for SIGHUP\n");
if (signal(SIGINT, sig_handler_term) == SIG_ERR)
fprintf(stderr, "cannot register handler for SIGINT\n");
/*
* Ignore SIGPIPE signal and handle the error directly when write()
* function fails. this will help us to catch the write failure rather
* than crashing the UOS.
*/
if (signal(SIGPIPE, SIG_IGN) == SIG_ERR)
fprintf(stderr, "cannot register handler for SIGPIPE\n");
while ((c = getopt_long(argc, argv, optstr, long_options,
&option_idx)) != -1) {