Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
10
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Open sidebar
emulab
emulab-devel
Commits
04b6cb58
Commit
04b6cb58
authored
Nov 01, 2017
by
Leigh Stoller
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'patch-2' into 'master'
Convert into daemon See merge request
!26
parents
c1ba157f
638b8ddf
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
34 additions
and
0 deletions
+34
-0
event/monitoring/shared-node-listener.c
event/monitoring/shared-node-listener.c
+34
-0
No files found.
event/monitoring/shared-node-listener.c
View file @
04b6cb58
...
...
@@ -25,6 +25,8 @@
#include <stdio.h>
#include <string.h>
#include <unistd.h>
#include <sys/types.h>
#include <sys/stat.h>
#include "event.h"
static
MYSQL
db
;
...
...
@@ -68,6 +70,31 @@ extern int main( void ) {
address_tuple_t
tuple
;
char
*
eid
,
buf
[
0x100
];
if
(
getuid
()
!=
0
)
{
printf
(
"Can only run as root
\n
"
);
exit
(
1
);
}
FILE
*
fp
;
char
mybuf
[
BUFSIZ
];
int
pid
;
sprintf
(
mybuf
,
"/var/run/shared-node-listener.pid"
);
fp
=
fopen
(
mybuf
,
"r"
);
if
(
fp
!=
NULL
)
{
fscanf
(
fp
,
"%d
\n
"
,
&
pid
);
(
void
)
fclose
(
fp
);
if
(
kill
(
pid
,
0
)
==
0
)
{
printf
(
"process already runnning
\n
"
);
exit
(
1
);
}
}
(
void
)
daemon
(
0
,
0
);
/* Shared pool experiments are not named consistently... grr. */
if
(
!
eaccess
(
"/proj/emulab-ops/exp/shared-nodes/tbdata/eventkey"
,
R_OK
)
)
eid
=
"shared-nodes"
;
...
...
@@ -111,6 +138,13 @@ extern int main( void ) {
return
1
;
}
fp
=
fopen
(
mybuf
,
"w"
);
if
(
fp
!=
NULL
)
{
fprintf
(
fp
,
"%d
\n
"
,
getpid
());
(
void
)
fclose
(
fp
);
}
event_main
(
h
);
return
0
;
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a 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