Fix job hangs on invalid/missing commands (#1187)

Original motivation:

> Not all systems have a `python` executable in their path. In this situation, sync will never complete with the message: "installing hererocks...". This fix will log the situation and callback with an error code.

Additionally helps in cases where `git` or commands passed via `run` are missing.
This commit is contained in:
hiimog 2023-01-11 01:27:40 -05:00 committed by GitHub
parent ef50f6fe40
commit b134cba054
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 8 additions and 1 deletions

View File

@ -50,7 +50,7 @@ end
local spawn = a.wrap(function(cmd, options, callback)
local handle = nil
local timer = nil
handle = loop.spawn(cmd, options, function(exit_code, signal)
handle, pid = loop.spawn(cmd, options, function(exit_code, signal)
handle:close()
if timer ~= nil then
timer:stop()
@ -78,6 +78,13 @@ local spawn = a.wrap(function(cmd, options, callback)
end
end
if handle == nil then
-- pid is an error string in this case
log.error(string.format("Failed spawning command: %s because %s", cmd, pid))
callback(-1, pid)
return
end
if options.timeout then
timer = loop.new_timer()
timer:start(options.timeout, 0, function()