Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
B
babeld
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
nexedi
babeld
Commits
a6388605
Commit
a6388605
authored
Mar 10, 2008
by
Juliusz Chroboczek
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Reopen log file on SIGUSR2.
parent
c75e7063
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
39 additions
and
20 deletions
+39
-20
babel.c
babel.c
+39
-20
No files found.
babel.c
View file @
a6388605
...
...
@@ -91,6 +91,7 @@ static volatile sig_atomic_t exiting = 0, dumping = 0, changed = 0;
static
int
kernel_routes_callback
(
int
changed
,
void
*
closure
);
static
void
init_signals
(
void
);
static
void
dump_tables
(
FILE
*
out
);
static
int
reopen_logfile
();
int
main
(
int
argc
,
char
**
argv
)
...
...
@@ -264,27 +265,11 @@ main(int argc, char **argv)
if
(
logfile
==
NULL
)
logfile
=
"/var/log/babel.log"
;
}
if
(
logfile
)
{
int
lfd
=
open
(
logfile
,
O_CREAT
|
O_WRONLY
|
O_APPEND
,
0644
);
if
(
lfd
<
0
)
{
perror
(
"open(logfile)"
);
goto
fail
;
}
fflush
(
stdout
);
fflush
(
stderr
);
rc
=
dup2
(
lfd
,
1
);
if
(
rc
<
0
)
{
perror
(
"dup2(logfile, 1)"
);
goto
fail
;
}
rc
=
dup2
(
lfd
,
2
);
if
(
rc
<
0
)
{
perror
(
"dup2(logfile, 2)"
);
goto
fail
;
}
close
(
lfd
);
rc
=
reopen_logfile
();
if
(
rc
<
0
)
{
perror
(
"reopen_logfile()"
);
goto
fail
;
}
fd
=
open
(
"/dev/null"
,
O_RDONLY
);
...
...
@@ -610,6 +595,11 @@ main(int argc, char **argv)
kernel_dump_time
=
now
.
tv_sec
;
check_neighbours_time
=
now
;
expiry_time
=
now
.
tv_sec
;
rc
=
reopen_logfile
();
if
(
rc
<
0
)
{
perror
(
"reopen_logfile"
);
break
;
}
changed
=
0
;
}
...
...
@@ -916,6 +906,35 @@ dump_tables(FILE *out)
fflush
(
out
);
}
static
int
reopen_logfile
()
{
int
lfd
,
rc
;
if
(
logfile
==
NULL
)
return
0
;
lfd
=
open
(
logfile
,
O_CREAT
|
O_WRONLY
|
O_APPEND
,
0644
);
if
(
lfd
<
0
)
return
-
1
;
fflush
(
stdout
);
fflush
(
stderr
);
rc
=
dup2
(
lfd
,
1
);
if
(
rc
<
0
)
return
-
1
;
rc
=
dup2
(
lfd
,
2
);
if
(
rc
<
0
)
return
-
1
;
if
(
lfd
>
2
)
close
(
lfd
);
return
1
;
}
static
int
kernel_routes_callback
(
int
changed
,
void
*
closure
)
{
...
...
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