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
c0735a97
Commit
c0735a97
authored
22 years ago
by
Mark Grondona
Browse files
Options
Downloads
Patches
Plain Diff
o change slurmd daemonization to not close all fds
parent
5cf35ce4
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/common/daemonize.c
+24
-4
24 additions, 4 deletions
src/common/daemonize.c
src/slurmd/shm.c
+4
-1
4 additions, 1 deletion
src/slurmd/shm.c
src/slurmd/slurmd.c
+29
-2
29 additions, 2 deletions
src/slurmd/slurmd.c
with
57 additions
and
7 deletions
src/common/daemonize.c
+
24
−
4
View file @
c0735a97
...
@@ -71,15 +71,35 @@ daemon(int nochdir, int noclose)
...
@@ -71,15 +71,35 @@ daemon(int nochdir, int noclose)
default:
_exit
(
0
);
/* exit parent */
default:
_exit
(
0
);
/* exit parent */
}
}
if
(
!
nochdir
&&
chdir
(
"/"
)
<
0
)
if
(
!
nochdir
&&
chdir
(
"/"
)
<
0
)
{
fatal
(
"chdir(/): %m"
);
error
(
"chdir(/): %m"
);
return
-
1
;
}
/* Close all file descriptors if requested
*/
if
(
!
noclose
)
{
if
(
!
noclose
)
{
closeall
(
0
);
closeall
(
0
);
open
(
"/dev/null"
,
O_RDWR
);
open
(
"/dev/null"
,
O_RDWR
);
dup
(
0
);
dup2
(
0
,
STDOUT_FILENO
);
dup
(
0
);
dup2
(
0
,
STDERR_FILENO
);
}
else
{
/*
* Otherwise, dup stdin, stdout, and stderr onto /dev/null
*/
int
devnull
=
open
(
"/dev/null"
,
O_RDWR
);
if
(
devnull
<
0
)
error
(
"Unable to open /dev/null: %m"
);
if
(
dup2
(
devnull
,
STDIN_FILENO
)
<
0
)
error
(
"Unable to dup /dev/null onto stdin: %m"
);
if
(
dup2
(
devnull
,
STDOUT_FILENO
)
<
0
)
error
(
"Unable to dup /dev/null onto stdout: %m"
);
if
(
dup2
(
devnull
,
STDERR_FILENO
)
<
0
)
error
(
"Unable to dup /dev/null onto stderr: %m"
);
if
(
close
(
devnull
)
<
0
)
error
(
"Unable to close /dev/null: %m"
);
}
}
return
0
;
return
0
;
}
}
...
...
This diff is collapsed.
Click to expand it.
src/slurmd/shm.c
+
4
−
1
View file @
c0735a97
...
@@ -983,6 +983,8 @@ _shm_reopen()
...
@@ -983,6 +983,8 @@ _shm_reopen()
return
SLURM_FAILURE
;
return
SLURM_FAILURE
;
}
}
debug3
(
"successfully attached to slurmd shm"
);
/*
/*
* Lock and unlock semaphore to ensure data is initialized
* Lock and unlock semaphore to ensure data is initialized
*/
*/
...
@@ -996,6 +998,7 @@ _shm_reopen()
...
@@ -996,6 +998,7 @@ _shm_reopen()
}
}
_shm_unlock
();
_shm_unlock
();
debug3
(
"leaving shm_init()"
);
return
retval
;
return
retval
;
}
}
...
@@ -1046,7 +1049,7 @@ _shm_sane(void)
...
@@ -1046,7 +1049,7 @@ _shm_sane(void)
sem_getvalue
(
shm_lock
,
&
val
);
sem_getvalue
(
shm_lock
,
&
val
);
debug
(
"shm lock val = %d, last accessed at %s"
,
debug
3
(
"shm lock val = %d, last accessed at %s"
,
val
,
ctime
(
&
st
.
st_atime
));
val
,
ctime
(
&
st
.
st_atime
));
if
((
val
==
0
)
&&
((
time
(
NULL
)
-
st
.
st_atime
)
>
30
))
if
((
val
==
0
)
&&
((
time
(
NULL
)
-
st
.
st_atime
)
>
30
))
...
...
This diff is collapsed.
Click to expand it.
src/slurmd/slurmd.c
+
29
−
2
View file @
c0735a97
...
@@ -138,13 +138,23 @@ main (int argc, char *argv[])
...
@@ -138,13 +138,23 @@ main (int argc, char *argv[])
*/
*/
if
(
_slurmd_init
()
<
0
)
{
if
(
_slurmd_init
()
<
0
)
{
error
(
"slurmd initialization failed"
);
error
(
"slurmd initialization failed"
);
fflush
(
NULL
);
exit
(
1
);
exit
(
1
);
}
}
debug3
(
"slurmd initialization successful"
);
/*
* Become a daemon if desired.
* Do not chdir("/") or close all fd's
*/
if
(
conf
->
daemonize
)
if
(
conf
->
daemonize
)
daemon
(
1
,
0
);
daemon
(
1
,
1
);
debug3
(
"finished daemonize"
);
_kill_old_slurmd
();
_kill_old_slurmd
();
_create_msg_socket
();
_create_msg_socket
();
conf
->
pid
=
getpid
();
conf
->
pid
=
getpid
();
...
@@ -550,6 +560,8 @@ _create_msg_socket()
...
@@ -550,6 +560,8 @@ _create_msg_socket()
conf
->
lfd
=
ld
;
conf
->
lfd
=
ld
;
debug3
(
"succesfully opened slurm listen port %d"
,
conf
->
port
);
return
;
return
;
}
}
...
@@ -584,6 +596,13 @@ _slurmd_init()
...
@@ -584,6 +596,13 @@ _slurmd_init()
setrlimit
(
RLIMIT_NOFILE
,
&
rlim
);
setrlimit
(
RLIMIT_NOFILE
,
&
rlim
);
}
}
#ifndef NDEBUG
if
(
getrlimit
(
RLIMIT_CORE
,
&
rlim
)
==
0
)
{
rlim
.
rlim_cur
=
rlim
.
rlim_max
;
setrlimit
(
RLIMIT_CORE
,
&
rlim
);
}
#endif
/* !NDEBUG */
/*
/*
* Create a context for verifying slurm job credentials
* Create a context for verifying slurm job credentials
*/
*/
...
@@ -599,8 +618,15 @@ _slurmd_init()
...
@@ -599,8 +618,15 @@ _slurmd_init()
/*
/*
* Cleanup shared memory if so configured
* Cleanup shared memory if so configured
*/
*/
if
(
conf
->
shm_cleanup
)
if
(
conf
->
shm_cleanup
)
{
/*
* Need to kill any running slurmd's here so they do
* not fail to lock shared memory on exit
*/
_kill_old_slurmd
();
shm_cleanup
();
shm_cleanup
();
}
/*
/*
* Initialize slurmd shared memory
* Initialize slurmd shared memory
...
@@ -764,6 +790,7 @@ _usage()
...
@@ -764,6 +790,7 @@ _usage()
static
int
static
int
_set_slurmd_spooldir
(
void
)
_set_slurmd_spooldir
(
void
)
{
{
debug3
(
"initializing slurmd spool directory"
);
if
((
mkdir
(
conf
->
spooldir
,
0755
)
<
0
)
&&
(
errno
!=
EEXIST
))
{
if
((
mkdir
(
conf
->
spooldir
,
0755
)
<
0
)
&&
(
errno
!=
EEXIST
))
{
error
(
"mkdir(%s): %m"
,
conf
->
spooldir
);
error
(
"mkdir(%s): %m"
,
conf
->
spooldir
);
return
SLURM_ERROR
;
return
SLURM_ERROR
;
...
...
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