# How to make a demonized process

**URL:** <https://discourse.julialang.org/t/how-to-make-a-demonized-process/11614>\
**Category:** General Usage\
**Created:** [June 12, 2018, 5:50pm UTC](https://discourse.julialang.org/t/how-to-make-a-demonized-process/11614 "2018-06-12T17:50:48Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![haides](https://avatars.discourse-cdn.com/v4/letter/h/bcef8e/32.png) [@haides](https://discourse.julialang.org/u/haides)\
**Post date:** [June 12, 2018, 5:50pm UTC](https://discourse.julialang.org/t/how-to-make-a-demonized-process/11614/1 "2018-06-12T17:50:48Z")

</div>

Hello everyone. I am quite new to julia and it’s multiprocessing model.  
What I need is a way to make a demonized process in julia.  
In python I have done it through double fork but I have not been able to find a way for it in julia.  
I basicly need to have a long running process in background and detached from terminal that should be able to use sockets to send and receive information.  
Any help would be much appreciated.  
Thanks

---

<div class="post-metadata">

**Author:** ![ggggggggg](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/ggggggggg/32/265_2.png) [@ggggggggg](https://discourse.julialang.org/u/ggggggggg)\
**Post date:** [June 12, 2018, 6:59pm UTC](https://discourse.julialang.org/t/how-to-make-a-demonized-process/11614/2 "2018-06-12T18:59:08Z")

</div>

[Tasks](https://docs.julialang.org/en/stable/manual/control-flow/#man-tasks-1) are a control flow feature that allows computations to be suspended and resumed in a flexible manner. This feature is sometimes called by other names, such as symmetric coroutines, lightweight threads, cooperative multitasking, or one-shot continuations. Tasks provide concurrency within one thread.

You can also launch a work on a separate process, see [here](https://docs.julialang.org/en/stable/manual/parallel-computing/).

There is also multi-threading but it is experimental, and probably not your best choice.

---

<div class="post-metadata">

**Author:** ![jameson](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/jameson/32/23_2.png) [@jameson](https://discourse.julialang.org/u/jameson)\
**Post date:** [June 19, 2018, 5:18pm UTC](https://discourse.julialang.org/t/how-to-make-a-demonized-process/11614/3 "2018-06-19T17:18:33Z")

</div>

Like python, you can just fork again:

```julia
spawn(`$(Base.julia_cmd()) -e "subcommand"`)
exit(0)

```

Or at the terminal, you can also just run it in the background, without completely detaching control (by adding `&`, or hitting `^Z` and then running `bg 1`)

As an aside, I think most recent service management (such as launchd and systemd) now handle this, and prefer that you don’t double-fork and daemonize though.

---

<div class="post-metadata">

**Author:** ![haides](https://avatars.discourse-cdn.com/v4/letter/h/bcef8e/32.png) [@haides](https://discourse.julialang.org/u/haides)\
**Post date:** [June 21, 2018, 11:28am UTC](https://discourse.julialang.org/t/how-to-make-a-demonized-process/11614/4 "2018-06-21T11:28:54Z")

</div>

Thanks @jameson  
That was helpful.  
However after some research I realized that using systemd is better and it is not that difficult too. I am going to give it a try.  
Thanks
