mirror of
https://git.suyu.dev/suyu/AppImageKit-checkrt.git
synced 2025-12-23 15:54:10 +01:00
I don't know why, but getppid() returns wrong result for me when application is started
This commit is contained in:
parent
07e851fcc8
commit
b2ac83a76e
4 changed files with 40 additions and 7 deletions
17
env.c
17
env.c
|
|
@ -43,6 +43,21 @@ void env_free(char* const *env) {
|
|||
free((char**)env);
|
||||
}
|
||||
|
||||
pid_t get_parent_pid() {
|
||||
pid_t ppid = 0;
|
||||
char *s_ppid = getenv("PPID");
|
||||
|
||||
if(s_ppid) {
|
||||
ppid = atoi(s_ppid);
|
||||
}
|
||||
|
||||
if (!ppid) {
|
||||
ppid = getppid();
|
||||
}
|
||||
|
||||
return ppid;
|
||||
}
|
||||
|
||||
static size_t get_number_of_variables(FILE *file, char **buffer, size_t *len) {
|
||||
size_t number = 0;
|
||||
|
||||
|
|
@ -103,7 +118,7 @@ static char* const* read_env_from_process(pid_t pid) {
|
|||
}
|
||||
|
||||
char* const* read_parent_env() {
|
||||
pid_t ppid = getppid();
|
||||
pid_t ppid = get_parent_pid();
|
||||
return read_env_from_process(ppid);
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue