[erlang-questions] escript and ctrl+c

Garrett Smith g@REDACTED
Mon Apr 2 23:29:15 CEST 2012


Hi Vivek,

On Mon, Apr 2, 2012 at 12:23 PM, Vivek Ayer <vivek.ayer@REDACTED> wrote:
> Hi List,
>
> I've been using escripts to prototype erlang code. It's really great
> and you can have something functional (no pun intended) very quick,
> similar to prototyping in python.
>
> Anyways, escript serves all my needs except for shutdown signals. I
> can't quite figure out how make an exit action like 'Ctrl+C' trigger
> something like an 'exit' or 'stop' routine in my scripts. How would I
> go about accomplishing this? Help appreciated.

Not possible, sadly.

There are different approaches, but they're messy.

If you just need to perform some simple cleanup work after Ctrl-C --
you could write a wrapper in Python that handles the signal and
perform the cleanup. You'd call the escript using subprocess.Popen,
e.g.

If it's not so simple, I'd look at still using Python (or anything
that handles signals) as a front end -- and setup Erlang as a
server-of-sorts (e.g. distributed Erlang, run_erl/to_erl, sockets,
etc.)

Garrett



More information about the erlang-questions mailing list