Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
emulab-devel
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Package registry
Model registry
Operate
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Emmanuel Cecchet
emulab-devel
Commits
a08d6dcc
Commit
a08d6dcc
authored
22 years ago
by
Kirk Webb
Browse files
Options
Downloads
Patches
Plain Diff
Fixed slothd off-by-one pid issue. Slothd now writes its pid _after_ forking into the background.
parent
afd81380
Branches
Branches containing commit
Tags
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
sensors/slothd/slothd.c
+12
-12
12 additions, 12 deletions
sensors/slothd/slothd.c
with
12 additions
and
12 deletions
sensors/slothd/slothd.c
+
12
−
12
View file @
a08d6dcc
...
...
@@ -62,8 +62,6 @@ void usage(void) {
int
main
(
int
argc
,
char
**
argv
)
{
int
exitcode
=
-
1
;
int
pfd
;
char
pidbuf
[
10
];
static
SLOTHD_OPTS
mopts
;
static
SLOTHD_PACKET
mpkt
;
...
...
@@ -75,16 +73,6 @@ int main(int argc, char **argv) {
opts
=
&
mopts
;
pkt
=
&
mpkt
;
/* Try to get lock. If can't, then bail out. */
if
((
pfd
=
open
(
PIDFILE
,
O_EXCL
|
O_CREAT
|
O_RDWR
))
<
0
)
{
lerror
(
"Can't create lock file, quiting."
);
exit
(
1
);
}
fchmod
(
pfd
,
S_IRUSR
|
S_IRGRP
|
S_IROTH
);
sprintf
(
pidbuf
,
"%d"
,
getpid
());
write
(
pfd
,
pidbuf
,
sizeof
(
pidbuf
));
close
(
pfd
);
if
(
parse_args
(
argc
,
argv
)
<
0
)
{
fprintf
(
stderr
,
"Error processing arguments.
\n
"
);
}
...
...
@@ -177,6 +165,8 @@ int parse_args(int argc, char **argv) {
int
init_slothd
(
void
)
{
DIR
*
devs
;
int
pfd
;
char
pidbuf
[
10
];
char
bufstr
[
MAXDEVLEN
];
struct
dirent
*
dptr
;
struct
hostent
*
hent
;
...
...
@@ -257,6 +247,16 @@ int init_slothd(void) {
return
-
1
;
}
/* Try to get lock. If can't, then bail out. */
if
((
pfd
=
open
(
PIDFILE
,
O_EXCL
|
O_CREAT
|
O_RDWR
))
<
0
)
{
lerror
(
"Can't create lock file, quiting."
);
exit
(
1
);
}
fchmod
(
pfd
,
S_IRUSR
|
S_IRGRP
|
S_IROTH
);
sprintf
(
pidbuf
,
"%d"
,
getpid
());
write
(
pfd
,
pidbuf
,
strlen
(
pidbuf
));
close
(
pfd
);
return
0
;
}
...
...
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