From 93c33be846873f3be30a7f2afda90dfd9067ba07 Mon Sep 17 00:00:00 2001 From: Michael Kerrisk Date: Mon, 30 Oct 2017 10:01:12 +0100 Subject: [PATCH] sigaltstack.2: Add explicit error handling to example code Signed-off-by: Michael Kerrisk --- man2/sigaltstack.2 | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/man2/sigaltstack.2 b/man2/sigaltstack.2 index f1506cfba..189db1b3a 100644 --- a/man2/sigaltstack.2 +++ b/man2/sigaltstack.2 @@ -295,12 +295,17 @@ The following code segment demonstrates the use of stack_t ss; ss.ss_sp = malloc(SIGSTKSZ); -if (ss.ss_sp == NULL) - /* Handle error */; +if (ss.ss_sp == NULL) { + perror("malloc"); + exit(EXIT_FAILURE); +} + ss.ss_size = SIGSTKSZ; ss.ss_flags = 0; if (sigaltstack(&ss, NULL) == \-1) - /* Handle error */; + perror("sigaltstack"); + exit(EXIT_FAILURE); +} .EE .in .SH BUGS