[PATCH xorg-gtest] process: use fork(), not vfork()

Chase Douglas chase.douglas at canonical.com
Wed Aug 8 09:21:19 PDT 2012


On 08/07/2012 06:33 PM, Peter Hutterer wrote:
>  From the man page:
>    The vfork() function has the same effect as fork(2), except that the
>    behavior is undefined if the process created by vfork() either modifies
>    any data other than a variable of type pid_t used to store the return
>    value from vfork(), or returns from the function in which vfork() was
>    called, or calls any other function before  successfully  calling
>    _exit(2)  or  one  of  the exec(3) family of functions.
>
> We modify data and we call functions other than _exit/exec.
>
> Signed-off-by: Peter Hutterer <peter.hutterer at who-t.net>
> ---
>   src/process.cpp |    2 +-
>   1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/src/process.cpp b/src/process.cpp
> index debd92e..7df2b84 100644
> --- a/src/process.cpp
> +++ b/src/process.cpp
> @@ -52,7 +52,7 @@ void xorg::testing::Process::Start(const std::string &program, const std::vector
>     if (d_->pid != -1)
>       throw std::runtime_error("Attempting to start an already started process");
>
> -  d_->pid = vfork();
> +  d_->pid = fork();
>
>     if (d_->pid == -1) {
>       throw std::runtime_error("Failed to fork child process");

There was a time when vfork was followed directly by exec. That no 
longer is the case. Good catch :).

Reviewed-by: Chase Douglas <chase.douglas at canonical.com>

Pushed as commit 9d2dd4e86e4903eb1c20f6e936c7ca2df1cdb90f.

Thanks!

-- Chase


More information about the xorg-devel mailing list