Skip to content

Commit bfb1150

Browse files
committed
Display stderr from qsub on error
1 parent 5c53890 commit bfb1150

File tree

1 file changed

+16
-11
lines changed

1 file changed

+16
-11
lines changed

src/clib/lib/job_queue/torque_driver.cpp

Lines changed: 16 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -402,36 +402,40 @@ static void torque_debug(const torque_driver_type *driver, const char *fmt,
402402
}
403403

404404
static int torque_job_parse_qsub_stdout(const torque_driver_type *driver,
405-
const char *stdout_file) {
405+
const char *stdout_file,
406+
const char *stderr_file) {
406407
int jobid;
407408
{
408-
FILE *stream = util_fopen(stdout_file, "r");
409+
FILE *stdout_stream = util_fopen(stdout_file, "r");
409410

410-
char *jobid_string = util_fscanf_alloc_upto(stream, ".", false);
411+
char *jobid_string = util_fscanf_alloc_upto(stdout_stream, ".", false);
411412

412413
bool possible_jobid;
413414
if (jobid_string == NULL) {
414415
/* We get here if the '.' separator is not found */
415-
possible_jobid = util_fscanf_int(stream, &jobid);
416+
possible_jobid = util_fscanf_int(stdout_stream, &jobid);
416417
torque_debug(driver, "Torque job ID int: '%d'", jobid);
417418
} else {
418419
possible_jobid = util_sscanf_int(jobid_string, &jobid);
419420
torque_debug(driver, "Torque job ID string: '%s'", jobid_string);
420421
}
421422

422423
if (!possible_jobid) {
423-
char *file_content =
424+
char *stdout_content =
424425
util_fread_alloc_file_content(stdout_file, NULL);
426+
char *stderr_content =
427+
util_fread_alloc_file_content(stderr_file, NULL);
425428
fprintf(stderr, "Failed to get torque job id from file: %s \n",
426429
stdout_file);
427-
fprintf(stderr, "qsub command : %s \n",
428-
driver->qsub_cmd);
429-
fprintf(stderr, "File content: [%s]\n", file_content);
430-
free(file_content);
430+
fprintf(stderr, "qsub command: %s \n", driver->qsub_cmd);
431+
fprintf(stderr, "qsub output: %s\n", stdout_content);
432+
fprintf(stderr, "qsub errors: %s\n", stderr_content);
433+
free(stdout_content);
434+
free(stderr_content);
431435
util_exit("%s: \n", __func__);
432436
}
433437
free(jobid_string);
434-
fclose(stream);
438+
fclose(stdout_stream);
435439
}
436440
return jobid;
437441
}
@@ -560,7 +564,8 @@ static int torque_driver_submit_shell_job(torque_driver_type *driver,
560564
}
561565
}
562566

563-
job_id = torque_job_parse_qsub_stdout(driver, tmp_std_file);
567+
job_id =
568+
torque_job_parse_qsub_stdout(driver, tmp_std_file, tmp_err_file);
564569

565570
util_unlink_existing(tmp_std_file);
566571
util_unlink_existing(tmp_err_file);

0 commit comments

Comments
 (0)