Skip to content

Commit ca9b18d

Browse files
author
Vladimir Kotal
committed
report errno as string
1 parent 61aeb21 commit ca9b18d

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

pipe/pipe_sig.c

+4-4
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,19 @@
11
/*
22
* run like this and then press ^C
33
*
4-
* We could have used `jot 10` for generating the sequence
5-
* however it is not available on all systems except FreeBSD/Mac OS X.
6-
*
74
* for i in 1 2 3 4 5 6 7 8 9 10; do echo $i; sleep 1; done | \
85
* ./a.out | ./a.out | ./a.out | ./a.out
96
*
7+
* Side note: We could have used `jot 10` for generating the sequence however
8+
* it is not available on all systems except FreeBSD/Mac OS X.
109
*/
1110

1211
#include <stdio.h>
1312
#include <unistd.h>
1413
#include <stdlib.h>
1514
#include <errno.h>
1615
#include <signal.h>
16+
#include <string.h>
1717

1818
void
1919
handler(int yyy)
@@ -42,7 +42,7 @@ main(void)
4242
write(1, &c, 1);
4343
}
4444

45-
fprintf(stderr, "%d: error %d\n", getpid(), errno);
45+
fprintf(stderr, "%d: error %s\n", getpid(), strerror(errno));
4646

4747
return (1);
4848
}

0 commit comments

Comments
 (0)