Don't use fork()

Create issue
Issue #914 resolved
Erik Schnetter created an issue

It seems that it is in many cases not safe to call fork() in MPI applications. This page has some information. The upshot seems to be: - In many (most) cases, one can call system() or popen() to execute external processes while waiting for them. - It is generally not safe to call fork() to execute a certain task in the background. However, it should be possible to use threads in this case.


Comments (6)

  1. Erik Schnetter reporter
    • removed comment

    This is not about a particular thorn. This is about all source code in Cactus thorns that may be running under MPI. We should review the code, and add a note to the documentation, and maybe even report compiler or run-time warnings when fork() is called.

  2. Frank Löffler

    A quick grep over the ET doesn't reveal any usage of fork, except in Formaline - but there it is disabled by default.

  3. Roland Haas
    • removed comment

    I believe fork() is ok. exec() can be a problem and so is doing anything with MPI in the forked() process (including and in particular calling MPI_Finalize).

  4. Roland Haas
    • edited description
    • changed status to resolved

    There is no more (active) code in the ET that uses fork(). The only places where fork() still shows up in C code is Formaline (where it is disabled by default and PTHREADS is used instead) and OpenCLRunTime (where it is commented out altogether). In both cases there is a comment "Don't use fork, MPI may not like it". I believe this discussion only ticket can be closed.

  5. Log in to comment