This is the mail archive of the
mailing list for the Cygwin project.
RE: Interrupting program from command line
- From: "Hannu E K Nevalainen \(garbage mail\)" <garbage_collector at telia dot com>
- To: "Alex Vinokur" <alexvn at connect dot to>, <cygwin at cygwin dot com>
- Date: Thu, 26 Jun 2003 22:46:23 +0200
- Subject: RE: Interrupting program from command line
> From: email@example.com [mailto:firstname.lastname@example.org]On Behalf
> Of Alex Vinokur
> I have some program that works endlessly.
> I want the program to be interrupted in some time after starting.
> Is it possible to do that from command?
> Something like (pseudo-code) :
> $ run 6 sec my_program,
I think it should be possible to create a script that does this, with the
help of the internal job control of bash. i.e. catch the PID of a started
job in a bash variable (e.g. set TASK_PID=`...`), then 'sleep' for a number
of seconds and finally 'kill -9' $TASK_PID .
$ info bash
<xc=0> $ sleep 120 &
<xc=0> $ kill -9 748
<xc=0> $ jobs
+ Killed sleep 120
/Hannu E K Nevalainen, 59~14'N, 17~12'E
~ <=> degree
--END OF MESSAGE--
Unsubscribe info: http://cygwin.com/ml/#unsubscribe-simple
Problem reports: http://cygwin.com/problems.html