Re: epoll and fork()

From: Mark Mielke (mark_at_mark.mielke.cc)
Date: 03/02/04

  • Next message: Jamey Hicks: "PATCH: add class_device_find"
    Date:	Tue, 2 Mar 2004 10:42:02 -0500
    To: Ben <linux-kernel-junk-email@slimyhorror.com>
    
    

    On Tue, Mar 02, 2004 at 12:31:20PM +0000, Ben wrote:
    > Is there a defined behaviour for what happens when a process with an epoll
    > fd forks?

    You found it. :-)

    > I've an app that inherits an epoll fd from its parent, and then
    > unregisters some file descriptors from the epoll set. This seems to have
    > the nasty side effect of unregistering the same file descriptors from the
    > parent process as well. Surely this can't be right?

    The epoll fd should probably be closed after the fork(), re-allocated,
    and then initialized to contain the file descriptors that you want to
    watch.

    mark

    -- 
    mark@mielke.cc/markm@ncf.ca/markm@nortelnetworks.com __________________________
    .  .  _  ._  . .   .__    .  . ._. .__ .   . . .__  | Neighbourhood Coder
    |\/| |_| |_| |/    |_     |\/|  |  |_  |   |/  |_   | 
    |  | | | | \ | \   |__ .  |  | .|. |__ |__ | \ |__  | Ottawa, Ontario, Canada
      One ring to rule them all, one ring to find them, one ring to bring them all
                           and in the darkness bind them...
                               http://mark.mielke.cc/
    -
    To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
    the body of a message to majordomo@vger.kernel.org
    More majordomo info at  http://vger.kernel.org/majordomo-info.html
    Please read the FAQ at  http://www.tux.org/lkml/
    

  • Next message: Jamey Hicks: "PATCH: add class_device_find"

    Relevant Pages

    • Re: Syslets, Threadlets, generic AIO support, v6
      ... kevent showed no significant advantage over epoll. ... yeah - this is a fundamental design question for Linus i guess :-) glibc ... 'hidden' file descriptors at the upper end of the fd space) so that it ...
      (Linux-Kernel)
    • Re: epoll gives broken results when interrupted with a signal
      ... >> The epoll is being used to monitor only a handful of file descriptors. ... >> by a parent process, and then passed on to the process doing the epoll. ... domain socket between the two processes. ...
      (Linux-Kernel)
    • Re: epoll and shared fds
      ... resulting file descriptors to P2 through a unix socket. ... P2 registers the received socket in his epollfd. ... Though the documentation says that if a process closes a file ... For epoll, a close is when the kernel file* is released (that is, when all ...
      (Linux-Kernel)
    • Re: epoll and shared fds
      ... resulting file descriptors to P2 through a unix socket. ... P2 registers the received socket in his epollfd. ... Though the documentation says that if a process closes a file ... For epoll, a close is when the kernel file* is released (that is, when all ...
      (Linux-Kernel)
    • Re: epoll and fork()
      ... > fd forks? ... > unregisters some file descriptors from the epoll set. ... > parent process as well. ... send the line "unsubscribe linux-kernel" in ...
      (Linux-Kernel)