I need a script that runs ‘A’ and send to it a signal that should terminate it, and I need to iterate that with different signals so what I want basically is
Launch A ->
send signal S to terminate A and check stuff ->
Relaunch A ->
send signal S1 ......
My problem is that in A I’ve a loop like:
while(1){
scanf()
...DO STUFF...
}
So using a script like
./A arguments
kill -s QUIT A'sPid
won’t work, because obviously it will not reach the kill line until A’s over, and it won’t without a signal or user input.
Can you give me any hint? Thanks, and sorry if it’s a banal question, but I’ve just started learning this stuff.
You need to put the
Ainstance into the background (see this), so that as it runs you can do something else, namely, send it a signal usingkill.To background a process put an
&at the end, i.e.:Once the background process is started the script will move on to the next command.