# Calling fork

**URL:** <https://discourse.julialang.org/t/calling-fork/72410>\
**Category:** General Usage\
**Created:** [December 1, 2021, 9:42pm UTC](https://discourse.julialang.org/t/calling-fork/72410 "2021-12-01T21:42:15Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![jzr](https://avatars.discourse-cdn.com/v4/letter/j/eb9ed0/32.png) [@jzr](https://discourse.julialang.org/u/jzr)\
**Post date:** [December 1, 2021, 9:42pm UTC](https://discourse.julialang.org/t/calling-fork/72410/1 "2021-12-01T21:42:15Z")

</div>

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

```julia
signal (6): Aborted

```

What is going wrong?

```julia
function main()
    pid = ccall(:fork, Cint, ())
    println(pid)
    while true
    end
end

if abspath(PROGRAM_FILE) == @ __FILE__
    main()
end

```

---

<div class="post-metadata">

**Author:** ![Keno](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/keno/32/285_2.png) [@Keno](https://discourse.julialang.org/u/Keno)\
**Post date:** [December 1, 2021, 9:50pm UTC](https://discourse.julialang.org/t/calling-fork/72410/2 "2021-12-01T21:50:41Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![giordano](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/giordano/32/2166_2.png) [@giordano](https://discourse.julialang.org/u/giordano)\
**Post date:** [December 2, 2021, 10:18am UTC](https://discourse.julialang.org/t/calling-fork/72410/3 "2021-12-02T10:18:38Z")

</div>

Adding to Keno’s answer, here is the relevant issue on Github (closed as won’t fix): [https://github.com/JuliaLang/julia/issues/8295](https://github.com/JuliaLang/julia/issues/8295)
