Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
emulab
emulab-devel
Commits
c3198437
Commit
c3198437
authored
Jan 11, 2002
by
Leigh B. Stoller
Browse files
Add HUP/INT/TERM signal handlers, primarily to avoid non-zero exit
status when we kill them off intentionally.
parent
25c8fde9
Changes
1
Hide whitespace changes
Inline
Side-by-side
os/frisbee.redux/server.c
View file @
c3198437
...
...
@@ -26,6 +26,10 @@ struct in_addr mcastif;
char
*
filename
;
struct
timeval
IdleTimeStamp
;
/* Forward decls */
void
quit
(
int
);
void
reinit
(
int
);
/*
* This structure defines the file we are spitting back.
*/
...
...
@@ -379,10 +383,14 @@ main(int argc, char **argv)
if
(
!
portnum
||
!
mcastaddr
.
s_addr
)
usage
();
signal
(
SIGINT
,
quit
);
signal
(
SIGTERM
,
quit
);
signal
(
SIGHUP
,
reinit
);
ServerLogInit
();
WorkQueueInit
();
ServerNetInit
();
filename
=
argv
[
0
];
if
(
access
(
filename
,
R_OK
)
<
0
)
pfatal
(
"Cannot read %s"
,
filename
);
...
...
@@ -419,3 +427,24 @@ main(int argc, char **argv)
exit
(
0
);
}
/*
* We catch the signals, but do not do anything. We exit with 0 status
* for these, since it indicates a desired shutdown.
*/
void
quit
(
int
sig
)
{
log
(
"Caught signal %d. Exiting ..."
,
sig
);
exit
(
0
);
}
/*
* We cannot reinit, so exit with non-zero to indicate it was unexpected.
*/
void
reinit
(
int
sig
)
{
log
(
"Caught signal %d. Exiting ..."
,
sig
);
exit
(
1
);
}
Write
Preview
Supports
Markdown
0%
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!
Cancel
Please
register
or
sign in
to comment