shell - wget won't stop after the surrounding subshell is killed -
see:
(wget http://stackoverflow.com/questions/ask && echo 'ok' || echo 'failed') & pid=$! sleep 1 # curcial kill $pid
if took out second line, there no hanging wegt after script finishes. want achieve kill wget process(or subshell whole) @ time , more processing based on exit code of wget. can explain me why wget in above script doesn't killed properly, , how make ? or there way can achieve want ?
consider following:
$ foo=foo $ export foo $ (foo=bar; echo foo $foo); echo foo $foo foo bar foo foo
a processes doesn't change parent's environment. goes shell processes , subshells, too.
braces alter logical priority without creating subshell:
$ foo=foo $ export foo $ { foo=bar; echo foo $foo); }; echo foo $foo foo bar foo bar
so think want
{ wget http://stackoverflow.com/questions/ask \ && echo 'ok' || echo 'failed'; } & kill $!
i want ... kill wget process (or subshell) ... , more processing based on exit code of wget.
i assume example simplified, , want know whether wget completed or not, , if killed. information in $!
, except echo 'failed'
return true. if that's issue, trap status before echoing message.
Comments
Post a Comment