fix SMJobSubmit fail on some osx#197
Conversation
SMJobSubmit will fail on some osx(tested in 10.11). when this happened, the job will be shown in the launchctl list but will never be executed (ShipIt not running) and the process will be terminated by later [NSApp terminate:self] as expected. so we manually launchctl start the ShipIt job. Signed-off-by: sunuslee <sunuslee@gmail.com>
|
I'm pretty conservative about making changes to Squirrel.Mac, given:
So to consider this PR, I'll need a more thorough description of the bug and how this is addressing it. |
| } | ||
|
|
||
| // wait for ShipIt to start. | ||
| sleep(1); |
There was a problem hiding this comment.
This seems to open us up to a race condition.
There was a problem hiding this comment.
during our own test, there might be some time before launchctl submit bring up ShipIt binary. so we just wait , for now.
otherwise, the check for shipIt is running might get the wrong result. but the update will still work. because what we did in the code is run another shipit.
|
|
||
| + (BOOL)isShipItRunning { | ||
| NSTask *checkShipItRunningTask = [[NSTask alloc] init]; | ||
| checkShipItRunningTask.launchPath=@"/usr/bin/pgrep"; |
There was a problem hiding this comment.
Can we use NSRunningApplication or NSWorkspace or something higher-level than shelling out to pgrep?
There was a problem hiding this comment.
hi, i am aware of NSRunningApplication and NSWorkspace. but ShipIt is a command line tool. it can not be found by [[NSWorkspace sharedWorkspace]runningApplications]; and it does not have a valid bundle id. so, we have to search by it's name.
correct me if i am wrong:)
| checkShipItRunningTask.launchPath=@"/usr/bin/pgrep"; | ||
| checkShipItRunningTask.arguments = @[@"ShipIt"]; | ||
| [checkShipItRunningTask launch]; | ||
| [checkShipItRunningTask waitUntilExit]; |
There was a problem hiding this comment.
This shouldn't be blocking.
| sleep(1); | ||
|
|
||
| if (![self isShipItRunning]) { | ||
| // ShipIt not running, possible something wrong with SumJobSubmit |
|
@joshaber when this bug happened , if the user finished downloading the new update file, the app will quit and won't launch again. because it's ShipIt's responsibility to bring up the app, but ShipIt can not start running in the first place, because SMJobSumit failed. |
But why does it fail? |
|
@joshaber but when this bug happened, this simple command will only show you the job in launchctl list , and not executing at all. |
|
@joshaber can you offer a better solution? |
|
I can't since I don't fully understand the bug or how it happens. But I'm hesitant to fix an apparent race condition by introducing another potential race condition. |
|
Closing due to inactivity. |
SMJobSubmit will fail on some osx(tested in 10.11).
when this happened, the job will be shown in the launchctl list
but will never be executed (ShipIt not running) and the process
will be terminated by later [NSApp terminate:self] as expected.
so we manually launchctl start the ShipIt job.
Signed-off-by: sunuslee sunuslee@gmail.com