# How to exit a Julia program without completely exit REPL or shutting down Julia?

**URL:** <https://discourse.julialang.org/t/how-to-exit-a-julia-program-without-completely-exit-repl-or-shutting-down-julia/66655>\
**Category:** General Usage\
**Created:** [August 19, 2021, 5:46am UTC](https://discourse.julialang.org/t/how-to-exit-a-julia-program-without-completely-exit-repl-or-shutting-down-julia/66655 "2021-08-19T05:46:01Z")\
**Posts on this page:** 1\
**Showing post:** 13

<div class="post-metadata">

**Author:** ![dlakelan](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/dlakelan/32/8491_2.png) [@dlakelan](https://discourse.julialang.org/u/dlakelan)\
**Post date:** [August 19, 2021, 5:38pm UTC](https://discourse.julialang.org/t/how-to-exit-a-julia-program-without-completely-exit-repl-or-shutting-down-julia/66655/13 "2021-08-19T17:38:41Z")

</div>

I mean, it would be pretty trivial to provide this through ccall right? I imagine I could do it this afternoon if I took the time to read up on ccall. But it would be better to be a package kind of maintained by some github organization, like JuliaStrings etc except with a “OS interaction” theme or something.

I just tested this on my computer, and it worked:

```julia
julia> ccall(:execvp,Int32,(Cstring,Array{Cstring}),"/home/dlakelan/julia-latest/bin/julia",Cstring[])

```

Also this:

```julia
julia> ccall(:execvp,Int32,(Cstring,Array{Cstring}),"julia",Cstring[])

```

since `execvp` searches the path in the same way the shell does and my personal julia install is in my path 😉

it should also be possible to create a function like this which just re-execs julia with the same arguments (figured out the specific sauce required).

```julia
julia> function reexec()
                 cmd = Base.julia_cmd()
                 @ccall execvp(cmd.exec[1]::Cstring,cmd.exec[2:end]::Ptr{Cstring})::Int32
       end
reexec (generic function with 1 method)

julia> reexec()
               _
   _ _ _(_)_ | Documentation: https://docs.julialang.org
  (_) | (_) (_) |
   _ _ _| |_ __ _ | Type "?" for help, "]?" for Pkg help.
  | | | | | | |/ _` | |
  | | |_| | | | (_| | | Version 1.7.0-beta3.0 (2021-07-07)
 _/ |\ __'_|_|_|\__'_| | release-1.7/e76c9dad42 (fork: 68 commits, 71 days)
|__/ |

```

---

_[View the full topic](https://discourse.julialang.org/t/how-to-exit-a-julia-program-without-completely-exit-repl-or-shutting-down-julia/66655)._
