Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions sysdeps/nacl/exit-thread.c
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,18 @@
#include <irt_syscalls.h>
#include <nptl/pthreadP.h>
#include <unistd.h>
#include <stdio.h>

void __exit_thread (int val)
{
/*
* The NaCl IRT fork function copies the process memory as a whole to the child, so we need to
* flush the stdio buffers before calling it.
* Issue #12:https://github.com/Lind-Project/native_client/issues/12
*/
fflush(stdout);
fflush(stderr);

/* We are about to die: make our pd "almost free" and wake up waiter. */
struct pthread* pd = THREAD_SELF;
int count;
Expand Down
9 changes: 9 additions & 0 deletions sysdeps/nacl/fork.c
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#include <errno.h>
#include <unistd.h>
#include <sysdep.h>
#include <stdio.h>

unsigned long int *__fork_generation_pointer;

Expand All @@ -11,6 +12,14 @@ unsigned long int *__fork_generation_pointer;
*/
int __libc_fork(void)
{
/*
* The NaCl IRT fork function copies the process memory as a whole to the child, so we need to
* flush the stdio buffers before calling it.
* Issue #12:https://github.com/Lind-Project/native_client/issues/12
*/
fflush(stdout);
fflush(stderr);

int ret = __nacl_irt_fork();
if (!ret && __fork_generation_pointer)
*__fork_generation_pointer += 4;
Expand Down