调用 execve() 时环境的各个方面是基于什么基础保留的?
On what basis are aspects of the environment kept upon a call to execve()?
我知道 exec
应该替换整个过程映像,但我也知道在调用 exec
- 系列函数之一时会保留文件描述符等内容。
调用 execve()
时环境的各个方面是基于什么基础保持的?
来自execve(3)
:
All process attributes are preserved during an execve(), except the
following:
The dispositions of any signals that are being caught are reset
to the default (signal(7)).
Any alternate signal stack is not preserved (sigaltstack(2)).
Memory mappings are not preserved (mmap(2)).
Attached System V shared memory segments are detached
(shmat(2)).
POSIX shared memory regions are unmapped (shm_open(3)).
Open POSIX message queue descriptors are closed
(mq_overview(7)).
Any open POSIX named semaphores are closed (sem_overview(7)).
POSIX timers are not preserved (timer_create(2)).
Any open directory streams are closed (opendir(3)).
Memory locks are not preserved (mlock(2), mlockall(2)).
Exit handlers are not preserved (atexit(3), on_exit(3)).
The floating-point environment is reset to the default (see
fenv(3)).
POSIX 也要求这样做(尽管被否定):
The new process shall inherit at least the following attributes from
the calling process image:
Nice value (see nice())
semadj values (see semop())
Process ID
Parent process ID
Process group ID
Session membership
Real user ID
Real group ID
Supplementary group IDs
Time left until an alarm clock signal (see alarm())
Current working directory
Root directory
File mode creation mask (see umask())
File size limit (see getrlimit() and setrlimit())
Process signal mask (see pthread_sigmask())
Pending signal (see sigpending())
tms_utime, tms_stime, tms_cutime, and tms_cstime (see times())
Resource limits
Controlling terminal
Interval timers
The initial thread of the new process shall inherit at least the
following attributes from the calling thread:
Signal mask (see sigprocmask() and pthread_sigmask())
Pending signals (see sigpending())
All other process attributes defined in this volume of POSIX.1-2017
shall be inherited in the new process image from the old process
image. All other thread attributes defined in this volume of
POSIX.1-2017 shall be inherited in the initial thread in the new
process image from the calling thread in the old process image. The
inheritance of process or thread attributes not defined by this volume
of POSIX.1-2017 is implementation-defined.
我知道 exec
应该替换整个过程映像,但我也知道在调用 exec
- 系列函数之一时会保留文件描述符等内容。
调用 execve()
时环境的各个方面是基于什么基础保持的?
来自execve(3)
:
All process attributes are preserved during an execve(), except the following:
The dispositions of any signals that are being caught are reset to the default (signal(7)).
Any alternate signal stack is not preserved (sigaltstack(2)).
Memory mappings are not preserved (mmap(2)).
Attached System V shared memory segments are detached (shmat(2)).
POSIX shared memory regions are unmapped (shm_open(3)).
Open POSIX message queue descriptors are closed (mq_overview(7)).
Any open POSIX named semaphores are closed (sem_overview(7)).
POSIX timers are not preserved (timer_create(2)).
Any open directory streams are closed (opendir(3)).
Memory locks are not preserved (mlock(2), mlockall(2)).
Exit handlers are not preserved (atexit(3), on_exit(3)).
The floating-point environment is reset to the default (see fenv(3)).
POSIX 也要求这样做(尽管被否定):
The new process shall inherit at least the following attributes from the calling process image:
Nice value (see nice())
semadj values (see semop())
Process ID
Parent process ID
Process group ID
Session membership
Real user ID
Real group ID
Supplementary group IDs
Time left until an alarm clock signal (see alarm())
Current working directory
Root directory
File mode creation mask (see umask())
File size limit (see getrlimit() and setrlimit())
Process signal mask (see pthread_sigmask())
Pending signal (see sigpending())
tms_utime, tms_stime, tms_cutime, and tms_cstime (see times())
Resource limits
Controlling terminal
Interval timers
The initial thread of the new process shall inherit at least the following attributes from the calling thread:
Signal mask (see sigprocmask() and pthread_sigmask())
Pending signals (see sigpending())
All other process attributes defined in this volume of POSIX.1-2017 shall be inherited in the new process image from the old process image. All other thread attributes defined in this volume of POSIX.1-2017 shall be inherited in the initial thread in the new process image from the calling thread in the old process image. The inheritance of process or thread attributes not defined by this volume of POSIX.1-2017 is implementation-defined.