Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
S
Slurm
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
tud-zih-energy
Slurm
Commits
580fd915
Commit
580fd915
authored
15 years ago
by
Moe Jette
Browse files
Options
Downloads
Patches
Plain Diff
Add support for SLURM_ERROR_EXIT env var to sattach
parent
b3e5d8fd
No related branches found
No related tags found
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
src/sattach/opt.c
+11
-9
11 additions, 9 deletions
src/sattach/opt.c
src/sattach/opt.h
+1
-0
1 addition, 0 deletions
src/sattach/opt.h
src/sattach/sattach.c
+31
-9
31 additions, 9 deletions
src/sattach/sattach.c
with
43 additions
and
18 deletions
src/sattach/opt.c
+
11
−
9
View file @
580fd915
...
...
@@ -86,6 +86,7 @@
/*---- global variables, defined in opt.h ----*/
opt_t
opt
;
int
error_exit
=
1
;
/*---- forward declarations of static functions ----*/
...
...
@@ -176,12 +177,12 @@ _get_pos_int(const char *arg, const char *what)
if
(
p
==
arg
||
!
xstring_is_whitespace
(
p
)
||
(
result
<
0L
))
{
error
(
"Invalid numeric value
\"
%s
\"
for %s."
,
arg
,
what
);
exit
(
1
);
exit
(
error_exit
);
}
if
(
result
>
INT_MAX
)
{
error
(
"Numeric argument %ld to big for %s."
,
result
,
what
);
exit
(
1
);
exit
(
error_exit
);
}
return
(
int
)
result
;
...
...
@@ -312,7 +313,7 @@ void set_options(const int argc, char **argv)
case
'?'
:
fprintf
(
stderr
,
"Try
\"
sattach --help
\"
for more "
"information
\n
"
);
exit
(
1
);
exit
(
error_exit
);
break
;
case
'h'
:
_help
();
...
...
@@ -361,8 +362,9 @@ void set_options(const int argc, char **argv)
opt
.
debugger_test
=
true
;
break
;
default:
fatal
(
"Unrecognized command line parameter %c"
,
error
(
"Unrecognized command line parameter %c"
,
opt_char
);
exit
(
error_exit
);
}
}
}
...
...
@@ -379,7 +381,7 @@ static void _parse_jobid_stepid(char *jobid_str)
error
(
"Did not find a period in the step ID string"
);
_usage
();
xfree
(
job
);
exit
(
1
);
exit
(
error_exit
);
}
else
{
*
ptr
=
'\0'
;
step
=
ptr
+
1
;
...
...
@@ -390,7 +392,7 @@ static void _parse_jobid_stepid(char *jobid_str)
error
(
"
\"
%s
\"
does not look like a jobid"
,
job
);
_usage
();
xfree
(
job
);
exit
(
1
);
exit
(
error_exit
);
}
stepid
=
strtol
(
step
,
&
ptr
,
10
);
...
...
@@ -398,7 +400,7 @@ static void _parse_jobid_stepid(char *jobid_str)
error
(
"
\"
%s
\"
does not look like a stepid"
,
step
);
_usage
();
xfree
(
job
);
exit
(
1
);
exit
(
error_exit
);
}
opt
.
jobid
=
(
uint32_t
)
jobid
;
...
...
@@ -426,13 +428,13 @@ static void _opt_args(int argc, char **argv)
if
(
leftover
!=
1
)
{
error
(
"too many parameters"
);
_usage
();
exit
(
1
);
exit
(
error_exit
);
}
_parse_jobid_stepid
(
*
(
argv
+
optind
));
if
(
!
_opt_verify
())
exit
(
1
);
exit
(
error_exit
);
}
/*
...
...
This diff is collapsed.
Click to expand it.
src/sattach/opt.h
+
1
−
0
View file @
580fd915
...
...
@@ -77,6 +77,7 @@ typedef struct sbatch_options {
}
opt_t
;
extern
opt_t
opt
;
extern
int
error_exit
;
/* process options:
* 1. set defaults
...
...
This diff is collapsed.
Click to expand it.
src/sattach/sattach.c
+
31
−
9
View file @
580fd915
...
...
@@ -2,7 +2,7 @@
* sattach.c - Attach to a running job step.
*****************************************************************************
* Copyright (C) 2006-2007 The Regents of the University of California.
* Copyright (C) 2008 Lawrence Livermore National Security.
* Copyright (C) 2008
-2009
Lawrence Livermore National Security.
* Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
* Written by Christopher J. Morrone <morrone2@llnl.gov>
* CODE-OCEC-09-009. All rights reserved.
...
...
@@ -71,6 +71,7 @@ static slurm_cred_t *_generate_fake_cred(uint32_t jobid, uint32_t stepid,
uint32_t
node_cnt
);
static
uint32_t
_nodeid_from_layout
(
slurm_step_layout_t
*
layout
,
uint32_t
taskid
);
static
void
_set_exit_code
(
void
);
static
int
_attach_to_tasks
(
uint32_t
jobid
,
uint32_t
stepid
,
slurm_step_layout_t
*
layout
,
...
...
@@ -81,6 +82,8 @@ static int _attach_to_tasks(uint32_t jobid,
uint16_t
*
io_ports
,
bitstr_t
*
tasks_started
);
int
global_rc
=
0
;
/**********************************************************************
* Message handler declarations
**********************************************************************/
...
...
@@ -117,8 +120,10 @@ int sattach(int argc, char *argv[])
client_io_t
*
io
;
log_init
(
xbasename
(
argv
[
0
]),
logopt
,
0
,
NULL
);
_set_exit_code
();
if
(
initialize_and_process_args
(
argc
,
argv
)
<
0
)
{
fatal
(
"sattach parameter parsing"
);
error
(
"sattach parameter parsing"
);
exit
(
error_exit
);
}
/* reinit log with new verbosity (if changed by command line) */
if
(
opt
.
verbose
||
opt
.
quiet
)
{
...
...
@@ -131,7 +136,7 @@ int sattach(int argc, char *argv[])
layout
=
slurm_job_step_layout_get
(
opt
.
jobid
,
opt
.
stepid
);
if
(
layout
==
NULL
)
{
error
(
"Could not get job step info: %m"
);
return
1
;
exit
(
error_exit
)
;
}
if
(
opt
.
layout_only
)
{
print_layout_info
(
layout
);
...
...
@@ -174,7 +179,21 @@ int sattach(int argc, char *argv[])
client_io_handler_destroy
(
io
);
_mpir_cleanup
();
return
0
;
return
global_rc
;
}
static
void
_set_exit_code
(
void
)
{
int
i
;
char
*
val
=
getenv
(
"SLURM_ERROR_EXIT"
);
if
(
val
)
{
i
=
atoi
(
val
);
if
(
i
==
0
)
error
(
"SLURM_ERROR_EXIT has zero value"
);
else
error_exit
=
i
;
}
}
static
uint32_t
...
...
@@ -479,9 +498,9 @@ static int _message_socket_accept(eio_obj_t *obj, List objs)
(
socklen_t
*
)
&
len
))
<
0
)
{
if
(
errno
==
EINTR
)
continue
;
if
(
errno
==
EAGAIN
||
errno
==
ECONNABORTED
||
errno
==
EWOULDBLOCK
)
{
if
(
(
errno
==
EAGAIN
)
||
(
errno
==
ECONNABORTED
)
||
(
errno
==
EWOULDBLOCK
)
)
{
return
SLURM_SUCCESS
;
}
error
(
"Error on msg accept socket: %m"
);
...
...
@@ -569,6 +588,7 @@ _exit_handler(message_thread_state_t *mts, slurm_msg_t *exit_msg)
error
(
"task %u exited with exit code %d"
,
msg
->
task_id_list
[
i
],
rc
);
}
global_rc
=
MAX
(
rc
,
global_rc
);
}
}
else
if
(
WIFSIGNALED
(
msg
->
return_code
))
{
for
(
i
=
0
;
i
<
msg
->
num_tasks
;
i
++
)
{
...
...
@@ -635,8 +655,10 @@ _mpir_init(int num_tasks)
{
MPIR_proctable_size
=
num_tasks
;
MPIR_proctable
=
xmalloc
(
sizeof
(
MPIR_PROCDESC
)
*
num_tasks
);
if
(
MPIR_proctable
==
NULL
)
fatal
(
"Unable to initialize MPIR_proctable: %m"
);
if
(
MPIR_proctable
==
NULL
)
{
error
(
"Unable to initialize MPIR_proctable: %m"
);
exit
(
error_exit
);
}
}
static
void
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment