macos fixs
This commit is contained in:
@@ -24,7 +24,6 @@
|
||||
|
||||
#include "comm/packet/packet_client.hpp"
|
||||
#include "drives/fuse/remotefuse/i_remote_instance.hpp"
|
||||
#include "events/event_system.hpp"
|
||||
#include "types/remote.hpp"
|
||||
|
||||
namespace repertory {
|
||||
|
||||
@@ -448,8 +448,7 @@ auto fuse_base::mount(std::vector<std::string> args) -> int {
|
||||
}
|
||||
|
||||
repertory::project_cleanup();
|
||||
exit(utils::create_daemon(main_func));
|
||||
return 0;
|
||||
return utils::create_daemon(main_func);
|
||||
}
|
||||
|
||||
auto fuse_base::open_(const char *path, struct fuse_file_info *f_info) -> int {
|
||||
|
||||
@@ -137,9 +137,10 @@ auto remote_fuse_drive::fgetattr_impl(std::string api_path, struct stat *u_stat,
|
||||
}
|
||||
|
||||
#if defined(__APPLE__)
|
||||
api_error remote_fuse_drive::fsetattr_x_impl(std::string api_path,
|
||||
struct setattr_x *attr,
|
||||
struct fuse_file_info *f_info) {
|
||||
auto remote_fuse_drive::fsetattr_x_impl(std::string api_path,
|
||||
struct setattr_x *attr,
|
||||
struct fuse_file_info *f_info)
|
||||
-> api_error {
|
||||
remote::setattr_x attributes{};
|
||||
attributes.valid = attr->valid;
|
||||
attributes.mode = attr->mode;
|
||||
|
||||
@@ -230,45 +230,48 @@ auto create_daemon(std::function<int()> main_func) -> int {
|
||||
return 1;
|
||||
}
|
||||
|
||||
if (pid == 0) {
|
||||
signal(SIGCHLD, SIG_DFL);
|
||||
if (setsid() < 0) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
auto second_pid = fork();
|
||||
if (second_pid < 0) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
if (second_pid > 0) {
|
||||
exit(0);
|
||||
}
|
||||
|
||||
close(STDIN_FILENO);
|
||||
close(STDOUT_FILENO);
|
||||
close(STDERR_FILENO);
|
||||
|
||||
auto file_desc = open("/dev/null", O_RDWR);
|
||||
if (file_desc < 0) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
dup2(file_desc, STDIN_FILENO);
|
||||
dup2(file_desc, STDOUT_FILENO);
|
||||
dup2(file_desc, STDERR_FILENO);
|
||||
|
||||
if (file_desc > STDERR_FILENO) {
|
||||
close(file_desc);
|
||||
}
|
||||
|
||||
umask(0);
|
||||
chdir("/");
|
||||
return main_func();
|
||||
if (pid > 0) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
signal(SIGCHLD, SIG_IGN);
|
||||
return 0;
|
||||
if (setsid() < 0) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
pid = fork();
|
||||
if (pid < 0) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
if (pid > 0) {
|
||||
_exit(0);
|
||||
}
|
||||
|
||||
close(STDIN_FILENO);
|
||||
close(STDOUT_FILENO);
|
||||
close(STDERR_FILENO);
|
||||
|
||||
auto file_desc = open("/dev/null", O_RDWR);
|
||||
if (file_desc < 0) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
dup2(file_desc, STDIN_FILENO);
|
||||
dup2(file_desc, STDOUT_FILENO);
|
||||
dup2(file_desc, STDERR_FILENO);
|
||||
|
||||
if (file_desc > STDERR_FILENO) {
|
||||
close(file_desc);
|
||||
}
|
||||
|
||||
signal(SIGCHLD, SIG_DFL);
|
||||
signal(SIGHUP, SIG_DFL);
|
||||
signal(SIGPIPE, SIG_IGN);
|
||||
|
||||
umask(0);
|
||||
chdir("/");
|
||||
|
||||
return main_func();
|
||||
}
|
||||
} // namespace repertory::utils
|
||||
|
||||
|
||||
Reference in New Issue
Block a user