Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
Tor
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Container Registry
Model registry
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
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
The Tor Project
Core
Tor
Commits
a57c27a1
Commit
a57c27a1
authored
6 years ago
by
Nick Mathewson
Browse files
Options
Downloads
Patches
Plain Diff
Call crypto_postfork on start_daemon() instead.
parent
622a2c6b
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
src/app/config/config.c
+3
-4
3 additions, 4 deletions
src/app/config/config.c
src/lib/process/daemon.c
+6
-4
6 additions, 4 deletions
src/lib/process/daemon.c
src/lib/process/daemon.h
+1
-1
1 addition, 1 deletion
src/lib/process/daemon.h
with
10 additions
and
9 deletions
src/app/config/config.c
+
3
−
4
View file @
a57c27a1
...
...
@@ -1411,7 +1411,8 @@ options_act_reversible(const or_options_t *old_options, char **msg)
* processes. */
if
(
running_tor
&&
options
->
RunAsDaemon
)
{
/* No need to roll back, since you can't change the value. */
start_daemon
();
if
(
start_daemon
())
crypto_postfork
();
}
#ifdef HAVE_SYSTEMD
...
...
@@ -2027,9 +2028,7 @@ options_act(const or_options_t *old_options)
/* Finish backgrounding the process */
if
(
options
->
RunAsDaemon
)
{
/* We may be calling this for the n'th time (on SIGHUP), but it's safe. */
int
forked
=
finish_daemon
(
options
->
DataDirectory
);
if
(
forked
)
crypto_postfork
();
finish_daemon
(
options
->
DataDirectory
);
}
/* See whether we need to enable/disable our once-a-second timer. */
...
...
This diff is collapsed.
Click to expand it.
src/lib/process/daemon.c
+
6
−
4
View file @
a57c27a1
...
...
@@ -41,15 +41,16 @@ static int daemon_filedes[2];
/** Start putting the process into daemon mode: fork and drop all resources
* except standard fds. The parent process never returns, but stays around
* until finish_daemon is called. (Note: it's safe to call this more
* than once: calls after the first are ignored.)
* than once: calls after the first are ignored.) Return true if we actually
* forked and this is the child; false otherwise.
*/
void
int
start_daemon
(
void
)
{
pid_t
pid
;
if
(
start_daemon_called
)
return
;
return
0
;
start_daemon_called
=
1
;
if
(
pipe
(
daemon_filedes
))
{
...
...
@@ -80,6 +81,7 @@ start_daemon(void)
exit
(
0
);
// exit ok: during daemonize, daemonizing.
else
exit
(
1
);
/* child reported error. exit ok: daemonize failed. */
return
0
;
// LCOV_EXCL_LINE unreachable
}
else
{
/* Child */
close
(
daemon_filedes
[
0
]);
/* we only write */
...
...
@@ -95,7 +97,7 @@ start_daemon(void)
}
set_main_thread
();
/* We are now the main thread. */
return
;
return
1
;
}
}
...
...
This diff is collapsed.
Click to expand it.
src/lib/process/daemon.h
+
1
−
1
View file @
a57c27a1
...
...
@@ -11,7 +11,7 @@
#ifndef TOR_DAEMON_H
#define TOR_DAEMON_H
void
start_daemon
(
void
);
int
start_daemon
(
void
);
int
finish_daemon
(
const
char
*
desired_cwd
);
#endif
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