View Issue Details
ID | Project | Category | View Status | Date Submitted | Last Update |
---|---|---|---|---|---|
0001614 | SOGo | SOPE | public | 2012-02-06 20:18 | 2012-10-25 18:18 |
Reporter | dekkers | Assigned To | |||
Priority | normal | Severity | minor | Reproducibility | always |
Status | resolved | Resolution | fixed | ||
Product Version | 1.3.11 | ||||
Fixed in Version | 2.0.2 | ||||
Summary | 0001614: Close all open file descriptors when daemonizing | ||||
Description | SOPE doesn't close all open file descriptors when daemonizing. Normally this isn't really a problem because there aren't any open file descriptors when SOGo is started, but it is a problem when SOGo is started from the Debian maintainer scripts and you're using debconf in those scripts. | ||||
Tags | No tags attached. | ||||
2012-02-06 20:18
|
0003-close-all-fds-on-daemon-start.patch (1,236 bytes)
From: Jeroen Dekkers <jeroen@dekkers.ch> Date: Mon, 5 Dec 2011 19:35:34 +0100 Subject: close-all-fds-on-daemon-start --- .../NGObjWeb/WOWatchDogApplicationMain.m | 7 ++++++- 1 files changed, 6 insertions(+), 1 deletions(-) diff --git a/sope-appserver/NGObjWeb/WOWatchDogApplicationMain.m b/sope-appserver/NGObjWeb/WOWatchDogApplicationMain.m index 94e7bae..bb46229 100644 --- a/sope-appserver/NGObjWeb/WOWatchDogApplicationMain.m +++ b/sope-appserver/NGObjWeb/WOWatchDogApplicationMain.m @@ -973,7 +973,7 @@ int WOWatchDogApplicationMain NSAutoreleasePool *pool; NSUserDefaults *ud; NSString *logFile, *nsPidFile; - int rc; + int rc, i; pid_t childPid; NSProcessInfo *processInfo; Class WOAppClass; @@ -1001,6 +1001,11 @@ int WOWatchDogApplicationMain logFile = [NSString stringWithFormat: @"/var/log/%@/%@.log", [processInfo processName], [processInfo processName]]; + + /* Close all open file descriptors */ + for (i = getdtablesize(); i >= 3; --i) + close(i); + freopen("/dev/null", "a", stdin); if (![logFile isEqualToString: @"-"]) { freopen([logFile cString], "a", stdout); freopen([logFile cString], "a", stderr); -- |
Looking at your patch, I understand what this is about. Note that I would expeet the parent process to close its file descriptors instead. |
|
No, the problem is that when you exec() something, you inherent all file descriptors unless they are marked close-on-exec. This causes debconf to hang (see also http://www.fifi.org/doc/debconf-doc/tutorial.html#AEN198) because it waits on the file descriptors that are kept open by the SOGo process. My patch doesn't touch stdout/stderr because those are already handled correctly. It does reopen stdin to /dev/null (because we don't use it for anything) and closes all other file descriptors (fd 3 and higher). |
|
Date Modified | Username | Field | Change |
---|---|---|---|
2012-02-06 20:18 | dekkers | New Issue | |
2012-02-06 20:18 | dekkers | File Added: 0003-close-all-fds-on-daemon-start.patch | |
2012-02-06 20:53 |
|
Note Added: 0003374 | |
2012-02-06 21:01 | dekkers | Note Added: 0003375 | |
2012-10-25 18:18 |
|
Status | new => resolved |
2012-10-25 18:18 |
|
Fixed in Version | => 2.0.2 |
2012-10-25 18:18 |
|
Resolution | open => fixed |
2012-10-25 18:18 |
|
Assigned To | => wsourdeau |