Code Comments
Programming Forum and web based access to our favorite programming groups.here is the code: while true do trap INT HUP ./foo ret=$? echo $ret fi done and here is the question? foo is a c program which will be in a block state after running it. When you do ctr-c foo comes out and returns 1. But the return code is 130 which is the exit for ctr-c for the script. Any way I can capture the return code for the program when I do ctr-c instead of the exit code of the script. Thanks
Post Follow-up to this messagedafella24 wrote: > here is the code: > > while true > do > trap INT HUP > ./foo > ret=$? > > echo $ret > fi > done It's not clear to me what you would like "trap INT HUP" to do exactly in this script code. > foo is a c program which will be in a block state after running it. > When you do ctr-c foo comes out and returns 1. But the return code is > 130 which is the exit for ctr-c for the script. Any way I can capture > the return code for the program when I do ctr-c instead of the exit > code of the script. So "foo" catches SIGINT. Then does just this work for your purpose? while true ; do ./foo ret=$? echo $ret done Or, if you wat to prevent the script itself being INTerrupted, add a "trap" to ignore ctrl-c inside the script: while true ; do trap "" INT ./foo ret=$? echo $ret done Regards, Heiko
Post Follow-up to this message
Show a Printable Version
Email This Page to Someone!
Receive updates to this thread
Powered by vBulletin
Copyright 2000-2006 Jelsoft Enterprises Limited.