Implementing posix_spawn with vfork()

ยอดดู 60 ครั้ง
ข้ามไปที่ข้อความที่ยังไม่อ่านรายการแรก

Jean-Baptiste Boric

ยังไม่อ่าน,
14 มิ.ย. 2558 10:33:1214/6/58
ถึง min...@googlegroups.com
Hi,

While trying to add the posix_spawn family of functions to Minix 3, I found out that when calling vfork() variables modified in the child process aren't modified in the parent process.

The attached test program "test_vfork.c" shows this output on Minix 3:

10.0.0.1# ./a.out
i=0
i=0
10.0.0.1#


But the expected output, as printed by my Linux box, is:

boricj@boricj-debian:~$ ./a.out
i=0
i=1
boricj@boricj-debian:~$


Disassembly of the resulting executable on Minix 3 showed that "i" wasn't optimized away.

While technically legal, this prevents me from recycling newlib's posix_spawn implementation as-is, which depends on vfork() not duplicating the address spaces, since it uses this to propagate error codes to the parent process.

Is vfork() being aliased to fork() the expected behavior in Minix 3? If so, how can I implement posix_spawn without violating the specs and (preferably) without kernel/VM support?

Attached is the patch adding posix_spawn functionality and "test_spawn.c" for testing quickly posix_spawn. Also, beware when testing with glibc, it's buggy (https://sourceware.org/bugzilla/show_bug.cgi?id=18433).
0001-libc-add-posix_spawn-family-of-functions.patch
test_spawn.c
test_vfork.c

Jean-Baptiste Boric

ยังไม่อ่าน,
19 มิ.ย. 2558 08:46:1919/6/58
ถึง min...@googlegroups.com
Nevermind, I got the vfork answer from a Tanenbaum talk, and I found a (messy but working) solution at stackoverflow.com/questions/3703013/what-can-cause-exec-to-fail-what-happens-next/.
ตอบทุกคน
ตอบกลับผู้สร้าง
ส่งต่อ
ข้อความใหม่ 0 รายการ