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 | ||||
|  | ||||
|   | ||||
| @@ -23,6 +23,7 @@ | ||||
| #define REPERTORY_INCLUDE_CLI_MOUNT_HPP_ | ||||
|  | ||||
| #include "cli/common.hpp" | ||||
| #include "initialize.hpp" | ||||
|  | ||||
| namespace repertory::cli::actions { | ||||
| [[nodiscard]] inline auto | ||||
| @@ -121,13 +122,12 @@ mount(std::vector<const char *> args, std::string data_directory, | ||||
|             << " Drive" << std::endl; | ||||
|   if (prov == provider_type::remote) { | ||||
|     try { | ||||
|       constexpr const std::uint8_t retry_count{30U}; | ||||
|  | ||||
|       auto remote_cfg = config.get_remote_config(); | ||||
|       remote_cfg.host_name_or_ip = remote_host; | ||||
|       remote_cfg.api_port = remote_port; | ||||
|       config.set_remote_config(remote_cfg); | ||||
|  | ||||
|       constexpr const std::uint8_t retry_count{30U}; | ||||
|       std::cout << "Connecting to remote [" << remote_host << ':' << remote_port | ||||
|                 << "] ..." << std::flush; | ||||
|       auto online{false}; | ||||
|   | ||||
| @@ -760,11 +760,11 @@ auto handlers::launch_process(provider_type prov, std::string_view name, | ||||
|     } | ||||
|     exec_args.push_back(nullptr); | ||||
|  | ||||
|     exit(utils::create_daemon([&]() -> int { | ||||
|     [[maybe_unused]] auto ret = utils::create_daemon([&]() -> int { | ||||
|       chdir(utils::path::get_parent_path(repertory_binary_).c_str()); | ||||
|       return execvp(exec_args.at(0U), | ||||
|                     const_cast<char *const *>(exec_args.data())); | ||||
|     })); | ||||
|     }); | ||||
| #endif // defined(_WIN32) | ||||
|  | ||||
|     return {}; | ||||
|   | ||||
		Reference in New Issue
	
	Block a user