gpt4 book ai didi

C wait3() int* status 或 int* stat_loc

转载 作者:塔克拉玛干 更新时间:2023-11-02 23:31:08 29 4
gpt4 key购买 nike

我确实要用wait3() .我一直在寻找 status/stat_loc 到底是什么,但我无法在任何地方找到它。

非常感谢任何解释!

最佳答案

man wait 解释status的语义:

   If status is not NULL, wait() and waitpid() store status information in
the int to which it points. This integer can be inspected with the
following macros (which take the integer itself as an argument, not a
pointer to it, as is done in wait() and waitpid()!):

WIFEXITED(status)
returns true if the child terminated normally, that is, by call‐
ing exit(3) or _exit(2), or by returning from main().

WEXITSTATUS(status)
returns the exit status of the child. This consists of the
least significant 8 bits of the status argument that the child
specified in a call to exit(3) or _exit(2) or as the argument
for a return statement in main(). This macro should only be
employed if WIFEXITED returned true.

WIFSIGNALED(status)
returns true if the child process was terminated by a signal.

WTERMSIG(status)
returns the number of the signal that caused the child process
to terminate. This macro should only be employed if WIFSIGNALED
returned true.

WCOREDUMP(status)
returns true if the child produced a core dump. This macro
should only be employed if WIFSIGNALED returned true. This
macro is not specified in POSIX.1-2001 and is not available on
some Unix implementations (e.g., AIX, SunOS). Only use this
enclosed in #ifdef WCOREDUMP ... #endif.

WIFSTOPPED(status)
returns true if the child process was stopped by delivery of a
signal; this is only possible if the call was done using WUN‐
TRACED or when the child is being traced (see ptrace(2)).

WSTOPSIG(status)
returns the number of the signal which caused the child to stop.
This macro should only be employed if WIFSTOPPED returned true.

WIFCONTINUED(status)
(since Linux 2.6.10) returns true if the child process was
resumed by delivery of SIGCONT.

关于C wait3() int* status 或 int* stat_loc,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8959809/

29 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com