On Wed, 21 Feb 2007, William James wrote:

On 2/21/07, James Carlson <[EMAIL PROTECTED]> wrote:
William James writes:
> On 2/21/07, James Carlson <[EMAIL PROTECTED]> wrote:
> > William James writes:
> > > Does Linux or POSIX specify a function which works like Solaris forkall?
> >
> > No.
>
> How can I fork all running threads in an application on Linux or other
> POSIX operating systems?

On Linux, I don't think you can do it.  This isn't a Linux-related
list, though, so if you're trying to port from Solaris to Linux
(why?), perhaps you'd get better answers on a different list.

I wish to write an application which is portable between Solaris and
Linux. Could you point me to a list which is appropriate for my
questions?

This is ok.

The solution for the problem "how to write portable applications" is "stick with portable interfaces".

All operating systems have interfaces that you may not, in the same form, find on other operating systems. If you stick to the common subset (that is, POSIX, as far as Linux/Solaris is concerned) you're ok.

Now "forkall()" is a Solaris-only thing. fork1() is the POSIX behaviour and therefore this is what you'd stick to.

Assuming that you really want fork. fork and multithreading don't mix very well. That's why all the documentation on all operating systems and in all standards docs I've seen says wrt. to fork() something like:

[quote http://www.opengroup.org/onlinepubs/007908799/xsh/fork.html]
...
Consequently, to avoid errors, the child process may only execute async-signal safe operations until such time as one of the exec functions is called.
...
[/quote]

I.e. as far as practial applicability goes, if you fork() in a MT process, you only fork in order to exec. Don't even think of doing anything else but exec in the child after you forked. It's not portable programming.

That Solaris has found a way to define what used to be undefined behaviour doesn't make every other operating system do the same...

FrankH.
_______________________________________________
opensolaris-code mailing list
[email protected]
http://mail.opensolaris.org/mailman/listinfo/opensolaris-code

Reply via email to