* [PATCH] [libc-test] pthread_atfork/fork regression test
@ 2017-11-10 20:59 Bobby Bingham
2018-02-07 21:01 ` Szabolcs Nagy
0 siblings, 1 reply; 2+ messages in thread
From: Bobby Bingham @ 2017-11-10 20:59 UTC (permalink / raw)
To: musl
---
src/regression/pthread_atfork-errno-clobber.c | 32 +++++++++++++++++++++++++++
1 file changed, 32 insertions(+)
create mode 100644 src/regression/pthread_atfork-errno-clobber.c
diff --git a/src/regression/pthread_atfork-errno-clobber.c b/src/regression/pthread_atfork-errno-clobber.c
new file mode 100644
index 0000000..ab3b378
--- /dev/null
+++ b/src/regression/pthread_atfork-errno-clobber.c
@@ -0,0 +1,32 @@
+#include <errno.h>
+#include <pthread.h>
+#include <stdio.h>
+#include <unistd.h>
+#include <sys/resource.h>
+#include <sys/types.h>
+#include <sys/wait.h>
+#include "test.h"
+
+#define TEST(c, ...) ((c) ? 1 : (t_error(#c" failed: " __VA_ARGS__),0))
+
+static void handler_errno(void)
+{
+ errno = 0;
+}
+
+int main(void)
+{
+ t_setrlim(RLIMIT_NPROC, 0);
+ pthread_atfork(handler_errno, handler_errno, handler_errno);
+
+ pid_t pid;
+ if (!TEST((pid = fork()) == -1, "fork succeeded despite rlimit\n")) {
+ if (!pid) _exit(0);
+ while (waitpid(pid, NULL, 0)<0 && errno==EINTR);
+ } else {
+ TEST(errno != 0, "fork failed but errno was clobbered\n");
+ }
+
+ return t_status;
+}
+
--
2.15.0
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: [PATCH] [libc-test] pthread_atfork/fork regression test
2017-11-10 20:59 [PATCH] [libc-test] pthread_atfork/fork regression test Bobby Bingham
@ 2018-02-07 21:01 ` Szabolcs Nagy
0 siblings, 0 replies; 2+ messages in thread
From: Szabolcs Nagy @ 2018-02-07 21:01 UTC (permalink / raw)
To: musl
* Bobby Bingham <koorogi@koorogi.info> [2017-11-10 14:59:18 -0600]:
> ---
> src/regression/pthread_atfork-errno-clobber.c | 32 +++++++++++++++++++++++++++
> 1 file changed, 32 insertions(+)
> create mode 100644 src/regression/pthread_atfork-errno-clobber.c
applied.
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2018-02-07 21:01 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-11-10 20:59 [PATCH] [libc-test] pthread_atfork/fork regression test Bobby Bingham
2018-02-07 21:01 ` Szabolcs Nagy
Code repositories for project(s) associated with this public inbox
https://git.vuxu.org/mirror/musl/
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).