qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Qemu-devel] [PATCH] linux-user: implement pipe2 syscall


From: Jamie Lokier
Subject: Re: [Qemu-devel] [PATCH] linux-user: implement pipe2 syscall
Date: Wed, 6 May 2009 11:53:37 +0100
User-agent: Mutt/1.5.13 (2006-08-11)

Martin Mohring wrote:
> >> The point of pipe2() with FD_CLOEXEC is to be atomic: make sure
> >> another thread can never see the file descriptor with FD_CLOEXEC not set.
> >   
> How do we want to handle if "O_CLOEXEC" is not defined on the host OS,
> because kernel too old (Debian Etch, CentOS 5)? Should it then return
> ENOSYS?

You can emulate it on any host OS using a mutex or read-write lock:

    - Acquire the lock for reading before calling the hosts's
      open/pipe/socket/etc.
    - Release the lock after calling the host's fcntl to set FD_CLOEXEC.

    - Acquire the lock for writing around emulation of fork, exec,
      clone and unshare.

There are ways to do it more efficiently without a lock, but I don't
think they are worth bothering with here.

-- Jamie




reply via email to

[Prev in Thread] Current Thread [Next in Thread]