# Different behavior of repl & julia for watching directory when receiving interrupting signal

**URL:** <https://discourse.julialang.org/t/different-behavior-of-repl-julia-for-watching-directory-when-receiving-interrupting-signal/12737>\
**Category:** General Usage\
**Tags:** question\
**Created:** [July 30, 2018, 12:45pm UTC](https://discourse.julialang.org/t/different-behavior-of-repl-julia-for-watching-directory-when-receiving-interrupting-signal/12737 "2018-07-30T12:45:11Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![oniter](https://avatars.discourse-cdn.com/v4/letter/o/df705f/32.png) [@oniter](https://discourse.julialang.org/u/oniter)\
**Post date:** [July 30, 2018, 12:45pm UTC](https://discourse.julialang.org/t/different-behavior-of-repl-julia-for-watching-directory-when-receiving-interrupting-signal/12737/1 "2018-07-30T12:45:11Z")

</div>

If I observe a directory for changes but send a signal to interrupt the script before any changes happen I got an unhandled error message. This is not the case using the code in the REPL or if there was a change in directory before.

So what I’m doing wrong here? Thx for answers and hints as always.

Here are the code lines (sorry I dont see how to format the code lines nicely):

#handle interruption - not needed in REPL  
ccall(:jl\_exit\_on\_sigint, Void, (Cint,), 0)

#directory to observe  
dir = “/path\_to\_dir/”

while true

```
try w = watch_file(dir,-1)
    if w.changed
        println("changed")
    end
catch x
    return error("Recieved interupting signal while watching $dir")
end

```

end

How I said, if any change happens before the interrupting signal comes all works fine.  
Otherwise I got this error:

> ERROR (unhandled task failure): InterruptException:  
> Stacktrace:  
> [1] process\_events at ./libuv.jl:82 [inlined]  
> [2] wait() at ./event.jl:216  
> [3] wait(::Condition) at ./event.jl:27  
> [4] macro expansion at ./distributed/remotecall.jl:230 [inlined]  
> [5] (::Base.Distributed.##131#132)() at ./event.jl:73

and the script is still running.

Using julia v0.6.2

---

<div class="post-metadata">

**Author:** ![oniter](https://avatars.discourse-cdn.com/v4/letter/o/df705f/32.png) [@oniter](https://discourse.julialang.org/u/oniter)\
**Post date:** [August 5, 2018, 4:18am UTC](https://discourse.julialang.org/t/different-behavior-of-repl-julia-for-watching-directory-when-receiving-interrupting-signal/12737/2 "2018-08-05T04:18:38Z")

</div>

Huuhuu, tock tock 😉

No hints nor explanations?

Can someone confirm that behavior?  
Should I open a bug in github?  
Or is this an user fault?

Thx for reading & answering.

---

<div class="post-metadata">

**Author:** ![oniter](https://avatars.discourse-cdn.com/v4/letter/o/df705f/32.png) [@oniter](https://discourse.julialang.org/u/oniter)\
**Post date:** [August 6, 2018, 8:44am UTC](https://discourse.julialang.org/t/different-behavior-of-repl-julia-for-watching-directory-when-receiving-interrupting-signal/12737/3 "2018-08-06T08:44:57Z")

</div>

This behavior is not present at julia version 0.7.0-rc2.
