From de21c6ec21e1a745fd5d9c4878218fb4d07f0737 Mon Sep 17 00:00:00 2001 From: guenther <> Date: Sun, 20 Jul 2014 01:38:40 +0000 Subject: Make sure the correct errno is reported by warn* or err* and not the errno of an intervening cleanup operation like close/unlink/etc. Diff from Doug Hogan (doug (at) acyclic.org) --- src/regress/lib/libc/stdio_threading/fwrite/fwrite_test.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'src/regress/lib/libc/stdio_threading/fwrite') diff --git a/src/regress/lib/libc/stdio_threading/fwrite/fwrite_test.c b/src/regress/lib/libc/stdio_threading/fwrite/fwrite_test.c index 621c5cb6e8..86c450cbc9 100755 --- a/src/regress/lib/libc/stdio_threading/fwrite/fwrite_test.c +++ b/src/regress/lib/libc/stdio_threading/fwrite/fwrite_test.c @@ -46,11 +46,12 @@ main(void) strlcpy(sfn, "/tmp/barnacles.XXXXXXXX", sizeof(sfn)); if ((fd = mkstemp(sfn)) == -1 || (sfp = fdopen(fd, "w+")) == NULL) { + int saved_errno = errno; if (fd != -1) { unlink(sfn); close(fd); } - err(1, "could not open temporary file"); + errc(1, saved_errno, "could not open temporary file"); } run_threads(fwrite_thread, sfp); -- cgit v1.2.3-55-g6feb