[erlang-questions] escript and ctrl+c
Vivek Ayer
vivek.ayer@REDACTED
Wed Apr 4 02:23:40 CEST 2012
Hey guys,
I think the bash script is the easiest route.
---
#!/bin/bash
trap ctrl_c INT
function ctrl_c() {
escript kill.es
exit 0
}
escript yourscript.es
while true
do
sleep 1
done
---
This is what I had planned: Start a UDP server in yourscript.es and
have a receive block that waits for a 'shutdown' message from kill.es.
Once it receives it 'shutdown' from the kill.es UDP client, it
executes erlang:halt().
What do you guys think?
Vivek
On Mon, Apr 2, 2012 at 3:35 PM, Vivek Ayer <vivek.ayer@REDACTED> wrote:
>
> Let's propose it for R16! :)
>
> On Mon, Apr 2, 2012 at 3:13 PM, Garrett Smith <g@REDACTED> wrote:
> > Heh, I wrote that :)
> >
> > No, that's definitely not what you're asking for. It's the most
> > misleading title imaginable!
> >
> > The title is generic across all 0MQ language examples -- but Erlang
> > doesn't support "handling ctrl-c cleanly". The example shows what the
> > equivalent shutdown handler might look like.
> >
> > Sorry about that.
> >
> > I'd still suggest a wrapper script in something like Python, which
> > handles signals well.
> >
> > Btw, given Erlang's server side heritage, I'm surprised it *does not*
> > handle signals. Most background OS processes do.
> >
> > On Mon, Apr 2, 2012 at 4:39 PM, Vivek Ayer <vivek.ayer@REDACTED> wrote:
> >> Looks like the zeromq community has already solved this:
> >>
> >> http://zguide.zeromq.org/es:interrupt
> >>
> >> If I'm not mistaken, this should do what I want. Can you all confirm?
> >>
> >> Vivek
> >>
> >> On Mon, Apr 2, 2012 at 10:23 AM, 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.
> >>>
> >>> Thanks,
> >>> Vivek
> >> _______________________________________________
> >> erlang-questions mailing list
> >> erlang-questions@REDACTED
> >> http://erlang.org/mailman/listinfo/erlang-questions
More information about the erlang-questions
mailing list