summaryrefslogtreecommitdiffstats
path: root/drivers/unix
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/unix')
-rw-r--r--drivers/unix/dir_access_unix.cpp6
-rw-r--r--drivers/unix/file_access_unix.cpp17
-rw-r--r--drivers/unix/file_access_unix.h1
-rw-r--r--drivers/unix/file_access_unix_pipe.cpp185
-rw-r--r--drivers/unix/file_access_unix_pipe.h97
-rw-r--r--drivers/unix/os_unix.cpp163
-rw-r--r--drivers/unix/os_unix.h11
7 files changed, 467 insertions, 13 deletions
diff --git a/drivers/unix/dir_access_unix.cpp b/drivers/unix/dir_access_unix.cpp
index 46efb45934..a4208829b7 100644
--- a/drivers/unix/dir_access_unix.cpp
+++ b/drivers/unix/dir_access_unix.cpp
@@ -289,7 +289,7 @@ String DirAccessUnix::get_drive(int p_drive) {
ERR_FAIL_INDEX_V(p_drive, list.size(), "");
- return list[p_drive];
+ return list.get(p_drive);
}
int DirAccessUnix::get_current_drive() {
@@ -419,7 +419,7 @@ Error DirAccessUnix::remove(String p_path) {
return FAILED;
}
- if (S_ISDIR(flags.st_mode)) {
+ if (S_ISDIR(flags.st_mode) && !is_link(p_path)) {
return ::rmdir(p_path.utf8().get_data()) == 0 ? OK : FAILED;
} else {
return ::unlink(p_path.utf8().get_data()) == 0 ? OK : FAILED;
@@ -435,7 +435,7 @@ bool DirAccessUnix::is_link(String p_file) {
struct stat flags = {};
if ((lstat(p_file.utf8().get_data(), &flags) != 0)) {
- return FAILED;
+ return false;
}
return S_ISLNK(flags.st_mode);
diff --git a/drivers/unix/file_access_unix.cpp b/drivers/unix/file_access_unix.cpp
index a35d8bfdde..210507c2c6 100644
--- a/drivers/unix/file_access_unix.cpp
+++ b/drivers/unix/file_access_unix.cpp
@@ -286,6 +286,23 @@ Error FileAccessUnix::get_error() const {
return last_error;
}
+Error FileAccessUnix::resize(int64_t p_length) {
+ ERR_FAIL_NULL_V_MSG(f, FAILED, "File must be opened before use.");
+ int res = ::ftruncate(fileno(f), p_length);
+ switch (res) {
+ case 0:
+ return OK;
+ case EBADF:
+ return ERR_FILE_CANT_OPEN;
+ case EFBIG:
+ return ERR_OUT_OF_MEMORY;
+ case EINVAL:
+ return ERR_INVALID_PARAMETER;
+ default:
+ return FAILED;
+ }
+}
+
void FileAccessUnix::flush() {
ERR_FAIL_NULL_MSG(f, "File must be opened before use.");
fflush(f);
diff --git a/drivers/unix/file_access_unix.h b/drivers/unix/file_access_unix.h
index 553fbcf355..c0286dbff3 100644
--- a/drivers/unix/file_access_unix.h
+++ b/drivers/unix/file_access_unix.h
@@ -75,6 +75,7 @@ public:
virtual Error get_error() const override; ///< get last error
+ virtual Error resize(int64_t p_length) override;
virtual void flush() override;
virtual void store_8(uint8_t p_dest) override; ///< store a byte
virtual void store_16(uint16_t p_dest) override;
diff --git a/drivers/unix/file_access_unix_pipe.cpp b/drivers/unix/file_access_unix_pipe.cpp
new file mode 100644
index 0000000000..5d9a27ad05
--- /dev/null
+++ b/drivers/unix/file_access_unix_pipe.cpp
@@ -0,0 +1,185 @@
+/**************************************************************************/
+/* file_access_unix_pipe.cpp */
+/**************************************************************************/
+/* This file is part of: */
+/* GODOT ENGINE */
+/* https://godotengine.org */
+/**************************************************************************/
+/* Copyright (c) 2014-present Godot Engine contributors (see AUTHORS.md). */
+/* Copyright (c) 2007-2014 Juan Linietsky, Ariel Manzur. */
+/* */
+/* Permission is hereby granted, free of charge, to any person obtaining */
+/* a copy of this software and associated documentation files (the */
+/* "Software"), to deal in the Software without restriction, including */
+/* without limitation the rights to use, copy, modify, merge, publish, */
+/* distribute, sublicense, and/or sell copies of the Software, and to */
+/* permit persons to whom the Software is furnished to do so, subject to */
+/* the following conditions: */
+/* */
+/* The above copyright notice and this permission notice shall be */
+/* included in all copies or substantial portions of the Software. */
+/* */
+/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
+/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
+/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. */
+/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
+/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
+/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
+/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
+/**************************************************************************/
+
+#include "file_access_unix_pipe.h"
+
+#if defined(UNIX_ENABLED)
+
+#include "core/os/os.h"
+#include "core/string/print_string.h"
+
+#include <errno.h>
+#include <fcntl.h>
+#include <sys/stat.h>
+#include <sys/types.h>
+#include <unistd.h>
+
+Error FileAccessUnixPipe::open_existing(int p_rfd, int p_wfd) {
+ // Open pipe using handles created by pipe(fd) call in the OS.execute_with_pipe.
+ _close();
+
+ path_src = String();
+ unlink_on_close = false;
+ ERR_FAIL_COND_V_MSG(fd[0] >= 0 || fd[1] >= 0, ERR_ALREADY_IN_USE, "Pipe is already in use.");
+ fd[0] = p_rfd;
+ fd[1] = p_wfd;
+
+ last_error = OK;
+ return OK;
+}
+
+Error FileAccessUnixPipe::open_internal(const String &p_path, int p_mode_flags) {
+ _close();
+
+ path_src = p_path;
+ ERR_FAIL_COND_V_MSG(fd[0] >= 0 || fd[1] >= 0, ERR_ALREADY_IN_USE, "Pipe is already in use.");
+
+ path = String("/tmp/") + p_path.replace("pipe://", "").replace("/", "_");
+ struct stat st = {};
+ int err = stat(path.utf8().get_data(), &st);
+ if (err) {
+ if (mkfifo(path.utf8().get_data(), 0666) != 0) {
+ last_error = ERR_FILE_CANT_OPEN;
+ return last_error;
+ }
+ unlink_on_close = true;
+ } else {
+ ERR_FAIL_COND_V_MSG(!S_ISFIFO(st.st_mode), ERR_ALREADY_IN_USE, "Pipe name is already used by file.");
+ }
+
+ int f = ::open(path.utf8().get_data(), O_RDWR | O_CLOEXEC);
+ if (f < 0) {
+ switch (errno) {
+ case ENOENT: {
+ last_error = ERR_FILE_NOT_FOUND;
+ } break;
+ default: {
+ last_error = ERR_FILE_CANT_OPEN;
+ } break;
+ }
+ return last_error;
+ }
+
+ // Set close on exec to avoid leaking it to subprocesses.
+ fd[0] = f;
+ fd[1] = f;
+
+ last_error = OK;
+ return OK;
+}
+
+void FileAccessUnixPipe::_close() {
+ if (fd[0] < 0) {
+ return;
+ }
+
+ if (fd[1] != fd[0]) {
+ ::close(fd[1]);
+ }
+ ::close(fd[0]);
+ fd[0] = -1;
+ fd[1] = -1;
+
+ if (unlink_on_close) {
+ ::unlink(path.utf8().ptr());
+ }
+ unlink_on_close = false;
+}
+
+bool FileAccessUnixPipe::is_open() const {
+ return (fd[0] >= 0 || fd[1] >= 0);
+}
+
+String FileAccessUnixPipe::get_path() const {
+ return path_src;
+}
+
+String FileAccessUnixPipe::get_path_absolute() const {
+ return path_src;
+}
+
+uint8_t FileAccessUnixPipe::get_8() const {
+ ERR_FAIL_COND_V_MSG(fd[0] < 0, 0, "Pipe must be opened before use.");
+
+ uint8_t b;
+ if (::read(fd[0], &b, 1) == 0) {
+ last_error = ERR_FILE_CANT_READ;
+ b = '\0';
+ } else {
+ last_error = OK;
+ }
+ return b;
+}
+
+uint64_t FileAccessUnixPipe::get_buffer(uint8_t *p_dst, uint64_t p_length) const {
+ ERR_FAIL_COND_V(!p_dst && p_length > 0, -1);
+ ERR_FAIL_COND_V_MSG(fd[0] < 0, -1, "Pipe must be opened before use.");
+
+ uint64_t read = ::read(fd[0], p_dst, p_length);
+ if (read == p_length) {
+ last_error = ERR_FILE_CANT_READ;
+ } else {
+ last_error = OK;
+ }
+ return read;
+}
+
+Error FileAccessUnixPipe::get_error() const {
+ return last_error;
+}
+
+void FileAccessUnixPipe::store_8(uint8_t p_src) {
+ ERR_FAIL_COND_MSG(fd[1] < 0, "Pipe must be opened before use.");
+ if (::write(fd[1], &p_src, 1) != 1) {
+ last_error = ERR_FILE_CANT_WRITE;
+ } else {
+ last_error = OK;
+ }
+}
+
+void FileAccessUnixPipe::store_buffer(const uint8_t *p_src, uint64_t p_length) {
+ ERR_FAIL_COND_MSG(fd[1] < 0, "Pipe must be opened before use.");
+ ERR_FAIL_COND(!p_src && p_length > 0);
+ if (::write(fd[1], p_src, p_length) != (ssize_t)p_length) {
+ last_error = ERR_FILE_CANT_WRITE;
+ } else {
+ last_error = OK;
+ }
+}
+
+void FileAccessUnixPipe::close() {
+ _close();
+}
+
+FileAccessUnixPipe::~FileAccessUnixPipe() {
+ _close();
+}
+
+#endif // UNIX_ENABLED
diff --git a/drivers/unix/file_access_unix_pipe.h b/drivers/unix/file_access_unix_pipe.h
new file mode 100644
index 0000000000..8e7988791b
--- /dev/null
+++ b/drivers/unix/file_access_unix_pipe.h
@@ -0,0 +1,97 @@
+/**************************************************************************/
+/* file_access_unix_pipe.h */
+/**************************************************************************/
+/* This file is part of: */
+/* GODOT ENGINE */
+/* https://godotengine.org */
+/**************************************************************************/
+/* Copyright (c) 2014-present Godot Engine contributors (see AUTHORS.md). */
+/* Copyright (c) 2007-2014 Juan Linietsky, Ariel Manzur. */
+/* */
+/* Permission is hereby granted, free of charge, to any person obtaining */
+/* a copy of this software and associated documentation files (the */
+/* "Software"), to deal in the Software without restriction, including */
+/* without limitation the rights to use, copy, modify, merge, publish, */
+/* distribute, sublicense, and/or sell copies of the Software, and to */
+/* permit persons to whom the Software is furnished to do so, subject to */
+/* the following conditions: */
+/* */
+/* The above copyright notice and this permission notice shall be */
+/* included in all copies or substantial portions of the Software. */
+/* */
+/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
+/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
+/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. */
+/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
+/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
+/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
+/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
+/**************************************************************************/
+
+#ifndef FILE_ACCESS_UNIX_PIPE_H
+#define FILE_ACCESS_UNIX_PIPE_H
+
+#include "core/io/file_access.h"
+#include "core/os/memory.h"
+
+#include <stdio.h>
+
+#if defined(UNIX_ENABLED)
+
+class FileAccessUnixPipe : public FileAccess {
+ bool unlink_on_close = false;
+
+ int fd[2] = { -1, -1 };
+
+ mutable Error last_error = OK;
+ String path;
+ String path_src;
+
+ void _close();
+
+public:
+ Error open_existing(int p_rfd, int p_wfd);
+ virtual Error open_internal(const String &p_path, int p_mode_flags) override; ///< open a file
+
+ virtual bool is_open() const override; ///< true when file is open
+
+ virtual String get_path() const override; /// returns the path for the current open file
+ virtual String get_path_absolute() const override; /// returns the absolute path for the current open file
+
+ virtual void seek(uint64_t p_position) override {}
+ virtual void seek_end(int64_t p_position = 0) override {}
+ virtual uint64_t get_position() const override { return 0; }
+ virtual uint64_t get_length() const override { return 0; }
+
+ virtual bool eof_reached() const override { return false; }
+
+ virtual uint8_t get_8() const override; ///< get a byte
+ virtual uint64_t get_buffer(uint8_t *p_dst, uint64_t p_length) const override;
+
+ virtual Error get_error() const override; ///< get last error
+
+ virtual Error resize(int64_t p_length) override { return ERR_UNAVAILABLE; }
+ virtual void flush() override {}
+ virtual void store_8(uint8_t p_src) override; ///< store a byte
+ virtual void store_buffer(const uint8_t *p_src, uint64_t p_length) override; ///< store an array of bytes
+
+ virtual bool file_exists(const String &p_path) override { return false; }
+
+ virtual uint64_t _get_modified_time(const String &p_file) override { return 0; }
+ virtual BitField<FileAccess::UnixPermissionFlags> _get_unix_permissions(const String &p_file) override { return 0; }
+ virtual Error _set_unix_permissions(const String &p_file, BitField<FileAccess::UnixPermissionFlags> p_permissions) override { return ERR_UNAVAILABLE; }
+
+ virtual bool _get_hidden_attribute(const String &p_file) override { return false; }
+ virtual Error _set_hidden_attribute(const String &p_file, bool p_hidden) override { return ERR_UNAVAILABLE; }
+ virtual bool _get_read_only_attribute(const String &p_file) override { return false; }
+ virtual Error _set_read_only_attribute(const String &p_file, bool p_ro) override { return ERR_UNAVAILABLE; }
+
+ virtual void close() override;
+
+ FileAccessUnixPipe() {}
+ virtual ~FileAccessUnixPipe();
+};
+
+#endif // UNIX_ENABLED
+
+#endif // FILE_ACCESS_UNIX_PIPE_H
diff --git a/drivers/unix/os_unix.cpp b/drivers/unix/os_unix.cpp
index 74b703b09e..ce2553456d 100644
--- a/drivers/unix/os_unix.cpp
+++ b/drivers/unix/os_unix.cpp
@@ -37,6 +37,7 @@
#include "core/debugger/script_debugger.h"
#include "drivers/unix/dir_access_unix.h"
#include "drivers/unix/file_access_unix.h"
+#include "drivers/unix/file_access_unix_pipe.h"
#include "drivers/unix/net_socket_posix.h"
#include "drivers/unix/thread_posix.h"
#include "servers/rendering_server.h"
@@ -160,17 +161,20 @@ void OS_Unix::initialize_core() {
FileAccess::make_default<FileAccessUnix>(FileAccess::ACCESS_RESOURCES);
FileAccess::make_default<FileAccessUnix>(FileAccess::ACCESS_USERDATA);
FileAccess::make_default<FileAccessUnix>(FileAccess::ACCESS_FILESYSTEM);
+ FileAccess::make_default<FileAccessUnixPipe>(FileAccess::ACCESS_PIPE);
DirAccess::make_default<DirAccessUnix>(DirAccess::ACCESS_RESOURCES);
DirAccess::make_default<DirAccessUnix>(DirAccess::ACCESS_USERDATA);
DirAccess::make_default<DirAccessUnix>(DirAccess::ACCESS_FILESYSTEM);
NetSocketPosix::make_default();
IPUnix::make_default();
+ process_map = memnew((HashMap<ProcessID, ProcessInfo>));
_setup_clock();
}
void OS_Unix::finalize_core() {
+ memdelete(process_map);
NetSocketPosix::cleanup();
}
@@ -489,6 +493,111 @@ Dictionary OS_Unix::get_memory_info() const {
return meminfo;
}
+Dictionary OS_Unix::execute_with_pipe(const String &p_path, const List<String> &p_arguments) {
+#define CLEAN_PIPES \
+ if (pipe_in[0] >= 0) { \
+ ::close(pipe_in[0]); \
+ } \
+ if (pipe_in[1] >= 0) { \
+ ::close(pipe_in[1]); \
+ } \
+ if (pipe_out[0] >= 0) { \
+ ::close(pipe_out[0]); \
+ } \
+ if (pipe_out[1] >= 0) { \
+ ::close(pipe_out[1]); \
+ } \
+ if (pipe_err[0] >= 0) { \
+ ::close(pipe_err[0]); \
+ } \
+ if (pipe_err[1] >= 0) { \
+ ::close(pipe_err[1]); \
+ }
+
+ Dictionary ret;
+#ifdef __EMSCRIPTEN__
+ // Don't compile this code at all to avoid undefined references.
+ // Actual virtual call goes to OS_Web.
+ ERR_FAIL_V(ret);
+#else
+ // Create pipes.
+ int pipe_in[2] = { -1, -1 };
+ int pipe_out[2] = { -1, -1 };
+ int pipe_err[2] = { -1, -1 };
+
+ ERR_FAIL_COND_V(pipe(pipe_in) != 0, ret);
+ if (pipe(pipe_out) != 0) {
+ CLEAN_PIPES
+ ERR_FAIL_V(ret);
+ }
+ if (pipe(pipe_err) != 0) {
+ CLEAN_PIPES
+ ERR_FAIL_V(ret);
+ }
+
+ // Create process.
+ pid_t pid = fork();
+ if (pid < 0) {
+ CLEAN_PIPES
+ ERR_FAIL_V(ret);
+ }
+
+ if (pid == 0) {
+ // The child process.
+ Vector<CharString> cs;
+ cs.push_back(p_path.utf8());
+ for (const String &arg : p_arguments) {
+ cs.push_back(arg.utf8());
+ }
+
+ Vector<char *> args;
+ for (int i = 0; i < cs.size(); i++) {
+ args.push_back((char *)cs[i].get_data());
+ }
+ args.push_back(0);
+
+ ::close(STDIN_FILENO);
+ ::dup2(pipe_in[0], STDIN_FILENO);
+
+ ::close(STDOUT_FILENO);
+ ::dup2(pipe_out[1], STDOUT_FILENO);
+
+ ::close(STDERR_FILENO);
+ ::dup2(pipe_err[1], STDERR_FILENO);
+
+ CLEAN_PIPES
+
+ execvp(p_path.utf8().get_data(), &args[0]);
+ // The execvp() function only returns if an error occurs.
+ ERR_PRINT("Could not create child process: " + p_path);
+ raise(SIGKILL);
+ }
+ ::close(pipe_in[0]);
+ ::close(pipe_out[1]);
+ ::close(pipe_err[1]);
+
+ Ref<FileAccessUnixPipe> main_pipe;
+ main_pipe.instantiate();
+ main_pipe->open_existing(pipe_out[0], pipe_in[1]);
+
+ Ref<FileAccessUnixPipe> err_pipe;
+ err_pipe.instantiate();
+ err_pipe->open_existing(pipe_err[0], 0);
+
+ ProcessInfo pi;
+ process_map_mutex.lock();
+ process_map->insert(pid, pi);
+ process_map_mutex.unlock();
+
+ ret["stdio"] = main_pipe;
+ ret["stderr"] = err_pipe;
+ ret["pid"] = pid;
+
+#undef CLEAN_PIPES
+ return ret;
+#endif
+}
+
Error OS_Unix::execute(const String &p_path, const List<String> &p_arguments, String *r_pipe, int *r_exitcode, bool read_stderr, Mutex *p_pipe_mutex, bool p_open_console) {
#ifdef __EMSCRIPTEN__
// Don't compile this code at all to avoid undefined references.
@@ -497,8 +606,8 @@ Error OS_Unix::execute(const String &p_path, const List<String> &p_arguments, St
#else
if (r_pipe) {
String command = "\"" + p_path + "\"";
- for (int i = 0; i < p_arguments.size(); i++) {
- command += String(" \"") + p_arguments[i] + "\"";
+ for (const String &arg : p_arguments) {
+ command += String(" \"") + arg + "\"";
}
if (read_stderr) {
command += " 2>&1"; // Include stderr
@@ -538,8 +647,8 @@ Error OS_Unix::execute(const String &p_path, const List<String> &p_arguments, St
// The child process
Vector<CharString> cs;
cs.push_back(p_path.utf8());
- for (int i = 0; i < p_arguments.size(); i++) {
- cs.push_back(p_arguments[i].utf8());
+ for (const String &arg : p_arguments) {
+ cs.push_back(arg.utf8());
}
Vector<char *> args;
@@ -580,8 +689,8 @@ Error OS_Unix::create_process(const String &p_path, const List<String> &p_argume
Vector<CharString> cs;
cs.push_back(p_path.utf8());
- for (int i = 0; i < p_arguments.size(); i++) {
- cs.push_back(p_arguments[i].utf8());
+ for (const String &arg : p_arguments) {
+ cs.push_back(arg.utf8());
}
Vector<char *> args;
@@ -596,6 +705,11 @@ Error OS_Unix::create_process(const String &p_path, const List<String> &p_argume
raise(SIGKILL);
}
+ ProcessInfo pi;
+ process_map_mutex.lock();
+ process_map->insert(pid, pi);
+ process_map_mutex.unlock();
+
if (r_child_id) {
*r_child_id = pid;
}
@@ -618,14 +732,45 @@ int OS_Unix::get_process_id() const {
}
bool OS_Unix::is_process_running(const ProcessID &p_pid) const {
+ MutexLock lock(process_map_mutex);
+ const ProcessInfo *pi = process_map->getptr(p_pid);
+
+ if (pi && !pi->is_running) {
+ return false;
+ }
+
int status = 0;
if (waitpid(p_pid, &status, WNOHANG) != 0) {
+ if (pi) {
+ pi->is_running = false;
+ pi->exit_code = status;
+ }
return false;
}
return true;
}
+int OS_Unix::get_process_exit_code(const ProcessID &p_pid) const {
+ MutexLock lock(process_map_mutex);
+ const ProcessInfo *pi = process_map->getptr(p_pid);
+
+ if (pi && !pi->is_running) {
+ return pi->exit_code;
+ }
+
+ int status = 0;
+ if (waitpid(p_pid, &status, WNOHANG) != 0) {
+ status = WIFEXITED(status) ? WEXITSTATUS(status) : status;
+ if (pi) {
+ pi->is_running = false;
+ pi->exit_code = status;
+ }
+ return status;
+ }
+ return -1;
+}
+
String OS_Unix::get_locale() const {
if (!has_environment("LANG")) {
return "en";
@@ -639,7 +784,7 @@ String OS_Unix::get_locale() const {
return locale;
}
-Error OS_Unix::open_dynamic_library(const String &p_path, void *&p_library_handle, bool p_also_set_library_path, String *r_resolved_path) {
+Error OS_Unix::open_dynamic_library(const String &p_path, void *&p_library_handle, GDExtensionData *p_data) {
String path = p_path;
if (FileAccess::exists(path) && path.is_relative_path()) {
@@ -663,8 +808,8 @@ Error OS_Unix::open_dynamic_library(const String &p_path, void *&p_library_handl
p_library_handle = dlopen(path.utf8().get_data(), GODOT_DLOPEN_MODE);
ERR_FAIL_NULL_V_MSG(p_library_handle, ERR_CANT_OPEN, vformat("Can't open dynamic library: %s. Error: %s.", p_path, dlerror()));
- if (r_resolved_path != nullptr) {
- *r_resolved_path = path;
+ if (p_data != nullptr && p_data->r_resolved_path != nullptr) {
+ *p_data->r_resolved_path = path;
}
return OK;
diff --git a/drivers/unix/os_unix.h b/drivers/unix/os_unix.h
index d3393c98ec..df269a59d3 100644
--- a/drivers/unix/os_unix.h
+++ b/drivers/unix/os_unix.h
@@ -37,6 +37,13 @@
#include "drivers/unix/ip_unix.h"
class OS_Unix : public OS {
+ struct ProcessInfo {
+ mutable bool is_running = true;
+ mutable int exit_code = -1;
+ };
+ HashMap<ProcessID, ProcessInfo> *process_map = nullptr;
+ Mutex process_map_mutex;
+
protected:
// UNIX only handles the core functions.
// inheriting platforms under unix (eg. X11) should handle the rest
@@ -55,7 +62,7 @@ public:
virtual Error get_entropy(uint8_t *r_buffer, int p_bytes) override;
- virtual Error open_dynamic_library(const String &p_path, void *&p_library_handle, bool p_also_set_library_path = false, String *r_resolved_path = nullptr) override;
+ virtual Error open_dynamic_library(const String &p_path, void *&p_library_handle, GDExtensionData *p_data = nullptr) override;
virtual Error close_dynamic_library(void *p_library_handle) override;
virtual Error get_dynamic_library_symbol_handle(void *p_library_handle, const String &p_name, void *&p_symbol_handle, bool p_optional = false) override;
@@ -76,10 +83,12 @@ public:
virtual Dictionary get_memory_info() const override;
virtual Error execute(const String &p_path, const List<String> &p_arguments, String *r_pipe = nullptr, int *r_exitcode = nullptr, bool read_stderr = false, Mutex *p_pipe_mutex = nullptr, bool p_open_console = false) override;
+ virtual Dictionary execute_with_pipe(const String &p_path, const List<String> &p_arguments) override;
virtual Error create_process(const String &p_path, const List<String> &p_arguments, ProcessID *r_child_id = nullptr, bool p_open_console = false) override;
virtual Error kill(const ProcessID &p_pid) override;
virtual int get_process_id() const override;
virtual bool is_process_running(const ProcessID &p_pid) const override;
+ virtual int get_process_exit_code(const ProcessID &p_pid) const override;
virtual bool has_environment(const String &p_var) const override;
virtual String get_environment(const String &p_var) const override;