Skip to content

Commit

Permalink
cmd/flux-wreck: check state and return codes in attach
Browse files Browse the repository at this point in the history
In flux-wreck attach, do not open stdin if job is already
completed. When opening stdin, check return code from
io watcher and die on failure.
  • Loading branch information
grondo committed Sep 11, 2016
1 parent 4fc8b19 commit 6a3622c
Showing 1 changed file with 13 additions and 9 deletions.
22 changes: 13 additions & 9 deletions src/cmd/flux-wreck
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ prog:SubCommand {
},
handler = function (self, arg)
local id = check_jobid_arg (self, arg[1])
local state = f:kvs_get ("lwj.%d.state")
local taskio, err = wreck.ioattach {
flux = f,
jobid = id,
Expand All @@ -74,15 +75,18 @@ prog:SubCommand {
if not taskio then
self:die ("Failed to connect to job %d: %s\n", id, err)
end
local kz, err = f:kz_open ("lwj."..id..".input.files.stdin", "w")
if kz then
f:iowatcher {
fd = posix.fileno (io.input()),
handler = function (iow, r)
if r.data then kz:write (r.data) end
if r.eof then kz:close () end
end
}
if state ~= "complete" and state ~= "reaped" then
local kz, err = f:kz_open ("lwj."..id..".input.files.stdin", "w")
if kz then
local iow, err = f:iowatcher {
fd = posix.fileno (io.input()),
handler = function (iow, r)
if r.data then kz:write (r.data) end
if r.eof then kz:close () end
end
}
if not iow then self:die ("error opening stdin: %s\n", err) end
end
end
if not taskio:complete() then f:reactor () end
if self.opt.s then
Expand Down

0 comments on commit 6a3622c

Please sign in to comment.