Don't let FUSE do daemonization, because it won't fork other threads than the main thread. Force applications to do daemonization themselves.
This commit is contained in:
parent
6d5c3aab4c
commit
c150c66534
@ -7,6 +7,7 @@
|
|||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include <messmer/cpp-utils/assert/assert.h>
|
#include <messmer/cpp-utils/assert/assert.h>
|
||||||
|
|
||||||
|
using std::vector;
|
||||||
using std::string;
|
using std::string;
|
||||||
|
|
||||||
namespace bf = boost::filesystem;
|
namespace bf = boost::filesystem;
|
||||||
@ -214,7 +215,22 @@ Fuse::Fuse(Filesystem *fs)
|
|||||||
}
|
}
|
||||||
|
|
||||||
void Fuse::run(int argc, char **argv) {
|
void Fuse::run(int argc, char **argv) {
|
||||||
fuse_main(argc, argv, operations(), (void*)this);
|
vector<char*> _argv(argv, argv + argc);
|
||||||
|
//If we allow fuse to fork the process, it wouldn't fork our threads with it (fork() only forks the main thread).
|
||||||
|
//So we always run it in foreground, and can do our own daemonization before calling this.
|
||||||
|
_addRunInForegroundOption(&_argv);
|
||||||
|
fuse_main(_argv.size(), _argv.data(), operations(), (void*)this);
|
||||||
|
}
|
||||||
|
|
||||||
|
void Fuse::_addRunInForegroundOption(vector<char*> *argv) {
|
||||||
|
//TODO Fix char* warning (-Wwrite-strings)
|
||||||
|
static char *foregroundOption = "-f";
|
||||||
|
bool hasRunInForegroundOption = std::find_if(argv->begin(), argv->end(),
|
||||||
|
[] (char *elem) {return string(elem) == string(foregroundOption);}
|
||||||
|
) != argv->end();
|
||||||
|
if (!hasRunInForegroundOption) {
|
||||||
|
argv->push_back(foregroundOption);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Fuse::running() const {
|
bool Fuse::running() const {
|
||||||
|
@ -5,6 +5,7 @@
|
|||||||
#include "params.h"
|
#include "params.h"
|
||||||
#include <cstdio>
|
#include <cstdio>
|
||||||
#include <string>
|
#include <string>
|
||||||
|
#include <vector>
|
||||||
#include <sys/stat.h>
|
#include <sys/stat.h>
|
||||||
#include <boost/filesystem.hpp>
|
#include <boost/filesystem.hpp>
|
||||||
#include "messmer/cpp-utils/macros.h"
|
#include "messmer/cpp-utils/macros.h"
|
||||||
@ -56,6 +57,7 @@ public:
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
Filesystem *_fs;
|
Filesystem *_fs;
|
||||||
|
void _addRunInForegroundOption(std::vector<char*> *argv);
|
||||||
bool _running;
|
bool _running;
|
||||||
|
|
||||||
DISALLOW_COPY_AND_ASSIGN(Fuse);
|
DISALLOW_COPY_AND_ASSIGN(Fuse);
|
||||||
|
Loading…
Reference in New Issue
Block a user