There are several parts to the answer:
Asynchronous do shell script: usually do shell scriptreturned only after the shell command completes, which means that you cannot manipulate processes inside the shell. However, you can get a command do shell scriptto asynchronously execute the backgrounding of the shell command that it executes, i.e.
do shell script "some_command &> /target/output &"
- . , , , ( /dev/null, ). echo $! , do shell script PID . , do
set thePID to do shell script "some_command &> /target/output & echo $!"
. TN2065. - do shell script "kill " & thePID.
ASObjC Runners - button was pressed true:
repeat until (button was pressed of progress window)
delay 0.5
end repeat
if (button was pressed of progress window) then do shell script "kill " & thePID
, script , :, , . ps PID, , , , ..
if (do shell script "ps -o comm= -p " & thePID & "; exit 0") is ""
true, .
:
tell application "ASObjC Runner"
reset progress
set properties of progress window to {button title:"Abort", button visible:true, indeterminate:true}
activate
show progress
try
set thePID to do shell script "blahblahblah &> /file/descriptor & echo $!"
repeat until (button was pressed of progress window)
tell me to if (do shell script "ps -o comm= -p " & thePID & "; exit 0") is "" then exit repeat
delay 0.5
end repeat
if (button was pressed of progress window) then tell me to do shell script "kill " & thePID
end try
hide progress
quit
end tell
, , , .