minecraft-pi-reborn/libreborn/include/libreborn/exec.h

50 lines
1.2 KiB
C
Raw Normal View History

2021-06-17 21:32:24 +00:00
#pragma once
#include <unistd.h>
#include <stdint.h>
#include <errno.h>
#include <string.h>
2022-03-14 23:09:25 +00:00
#include <sys/wait.h>
#include <fcntl.h>
2022-05-15 17:51:28 +00:00
#include <signal.h>
2021-06-17 21:32:24 +00:00
#include "log.h"
#include "string.h"
#include "util.h"
2022-03-14 23:09:25 +00:00
#ifdef __cplusplus
extern "C" {
#endif
2022-07-20 06:58:14 +00:00
// Set Environmental Variable
void set_and_print_env(const char *name, const char *value);
2021-06-17 21:32:24 +00:00
// Safe execvpe()
2022-07-20 06:58:14 +00:00
#define for_each_special_environmental_variable(handle) \
handle("LD_LIBRARY_PATH"); \
handle("GCONV_PATH"); \
handle("LD_PRELOAD");
void setup_exec_environment(int is_arm_component);
2022-03-14 23:09:25 +00:00
__attribute__((noreturn)) void safe_execvpe(const char *const argv[], const char *const envp[]);
2022-03-09 23:47:31 +00:00
// Chop Off Last Component
2022-03-14 23:09:25 +00:00
void chop_last_component(char **str);
2021-06-17 21:32:24 +00:00
// Get Binary Directory (Remember To Free)
2022-03-14 23:09:25 +00:00
char *get_binary_directory();
2022-03-09 23:47:31 +00:00
2022-03-14 23:09:25 +00:00
// Run Command And Get Output
2022-05-15 17:51:28 +00:00
char *run_command(const char *const command[], int *exit_status);
#define is_exit_status_success(status) (WIFEXITED(status) && WEXITSTATUS(status) == 0)
// Get Exit Status String
void get_exit_status_string(int status, char **out);
2022-03-14 23:09:25 +00:00
2022-05-14 02:36:12 +00:00
// Track Children
void track_child(pid_t pid);
void untrack_child(pid_t pid);
void murder_children();
2022-03-14 23:09:25 +00:00
#ifdef __cplusplus
2022-03-09 23:47:31 +00:00
}
2022-03-14 23:09:25 +00:00
#endif