Skip to content

Commit 71fbedb

Browse files
committed
shell: check return code of close(2) when writing batch script
Problem: The job shell batch plugin doesn't check the return code of the close(2) system call when writing a batch script using the old-style attributes.system.batch script. Check the return code and fail if nonzero.
1 parent 999efbf commit 71fbedb

File tree

1 file changed

+1
-2
lines changed

1 file changed

+1
-2
lines changed

src/shell/batch.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -97,11 +97,10 @@ batch_info_create (flux_shell_t *shell, json_t *batch)
9797
shell_debug ("Copying batch script size=%zu for job to %s",
9898
len,
9999
b->script);
100-
if (write_all (fd, data, len) < 0) {
100+
if (write_all (fd, data, len) < 0 || close (fd) < 0) {
101101
shell_log_error ("failed to write batch script");
102102
goto error;
103103
}
104-
close (fd);
105104
}
106105
return b;
107106
error:

0 commit comments

Comments
 (0)