Wandering Thoughts archives

2006-08-22

fork(), wait(), and threads

Something I've discovered through (painful) experience is that threaded programs cannot portably fork() in one thread and then wait() for the forked process in another one.

This will work in some environments but fail explosively in others; the one I stubbed my toe on was a Linux 2.4 kernel based system (without NPTL, which is the usual state of affairs for 2.4-based Linux distributions).

Admittedly, mixing threads and fork() is a bit perverse, but sometimes it's what you need to do.

(I saw this in a Python program, but Python isn't doing anything special in the POSIX threads department so I have to expect that it's completely generic.)

ThreadsAndFork written at 13:08:41; Add Comment


Page tools: See As Normal.
Search:
Login: Password:
Atom Syndication: Recent Pages, Recent Comments.

This dinky wiki is brought to you by the Insane Hackers Guild, Python sub-branch.