Calling fork

Julia has more sophisticated multi-processing tools but I want to experiment with some low level options. I expected this code to print the child pid from the parent and 0 from the child but it only prints from the parent and

signal (6): Aborted

What is going wrong?

function main()
    pid = ccall(:fork, Cint, ())
    while true

if abspath(PROGRAM_FILE) == @__FILE__

The julia runtime is not fork-safe (as is generally the case for multi-threaded programs). There are possibilities, but none of them easy. I would advise against attempting this.

1 Like

Adding to Keno’s answer, here is the relevant issue on Github (closed as won’t fix): fork support · Issue #8295 · JuliaLang/julia · GitHub

1 Like