libc/fdcheck: child process that uses the parent process'fd will crash

In many cases, it is legal for the child process to use the fd
created by the parent process,
so to improve compatibility, we allow the child process
to use the fd of the Parent process.

Signed-off-by: hujun5 <hujun5@xiaomi.com>
This commit is contained in:
hujun5 2023-06-12 12:36:15 +08:00 committed by Xiang Xiao
parent 387944b837
commit 04db52612e

View File

@ -75,6 +75,7 @@ int fdcheck_restore(int val)
{
int pid_expect;
int pid_now;
int ppid_now;
if (val <= 2)
{
@ -83,9 +84,11 @@ int fdcheck_restore(int val)
pid_expect = (val >> PID_SHIFT);
pid_now = (getpid() & PID_MASK);
if (pid_expect != pid_now)
ppid_now = (getppid() & PID_MASK);
if (pid_expect != pid_now && pid_expect != ppid_now)
{
ferr("pid_expect %d pid_now %d\n", pid_expect, pid_now);
ferr("pid_expect %d pid_now %d ppid_now %d\n",
pid_expect, pid_now, ppid_now);
PANIC();
}