Skip to content

Commit

Permalink
Fixed issue #14, Wrong terminationStatus due to not using WEXITSTATUS…
Browse files Browse the repository at this point in the history
… macro
  • Loading branch information
sveinbjornt committed Oct 3, 2016
1 parent d7b51e9 commit 5d6bfd0
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
2 changes: 2 additions & 0 deletions PrivilegedTaskExample/PrivilegedTaskExample/script.sh
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,5 @@ echo "Effective User ID:"
echo ""
echo "Current working directory:"
echo "$PWD"

exit 122
6 changes: 4 additions & 2 deletions STPrivilegedTask.m
Original file line number Diff line number Diff line change
Expand Up @@ -252,10 +252,12 @@ - (void)waitUntilExit

// check if task has terminated
- (void)checkTaskStatus
{
int pid = waitpid(_processIdentifier, &_terminationStatus, WNOHANG);
{
int status;
int pid = waitpid(_processIdentifier, &status, WNOHANG);
if (pid != 0) {
_isRunning = NO;
_terminationStatus = WEXITSTATUS(status);
[checkStatusTimer invalidate];
[[NSNotificationCenter defaultCenter] postNotificationName:STPrivilegedTaskDidTerminateNotification object:self];
if (_terminationHandler) {
Expand Down

0 comments on commit 5d6bfd0

Please sign in to comment.