Re: File descriptor suddenly goes bad

From: Dan Mills (dmills_at_spamblock.demon.co.uk)
Date: 10/02/04

  • Next message: James Antill: "Re: Descriptor passed w/SCM_RIGHTS is invalid"
    Date: Sat, 02 Oct 2004 21:12:18 +0100
    
    

    Kasper Dupont wrote:

    > Dan Mills wrote:
    >>
    >> Just a guess but do you fork and does the child then either exit or close
    >> the fd. There are IIRC some subtle issues involved here.
    >
    > That shouldn't cause any trouble. A shutdown call
    > on the socket might explain the problem.

    I had thought that there was some requirement to use _exit() in the child?

    <Reaches for APUE>

    If you open a file descriptor then fork the child inherits the open FD.
    Now closing it in one process is not a problem but some other socket
    operations may be.

    Does exit() shutdown any open sockets? How about _exit() which does less....

    Note that returning from main implies exit().

    Just guessing here.

    -- 
    ** The email address  *IS*  valid, do  NOT  remove the spamblock
    And on the evening of the first day the lord said...........
    .... LX 1, GO!; and there was light.
    

  • Next message: James Antill: "Re: Descriptor passed w/SCM_RIGHTS is invalid"

    Relevant Pages

    • TCP Server+perl
      ... Client each time a new connection is established at the Socket. ... each child completes processing it closes/ends. ... # Main loop control variable ... You exit the ...
      (comp.lang.perl.misc)
    • Re: fork defunct process, already forked twice
      ... // in parent, parent waits for child to exit ... //output a fork error message; ...
      (comp.unix.questions)
    • Re: Fork, Pipe, Dup2 etc.
      ... You MUST use _exit() in the child of a fork/vfork, ... Every process is the result of a fork or vfork! ... forkcopies stdio buffers and atexit calls. ...
      (comp.unix.programmer)
    • Re: mysql vs. fork
      ... what's the point in forcing an exit while we are exiting? ... only the at_exit handlers defined in the child process are ... That's bad because the server thinks he has one peer only. ... And if you use the connection's close method chances are that the server shuts down the socket and both clients suffer. ...
      (comp.lang.ruby)
    • Re: Should parents WIFSIGNALED(siginfo->si_status) be true EVEN IF the SIGNAL was caught by the
      ... Since the exit() will cause a SIGCHLD to the parent, ... returns true if the child process was terminated by a signal. ... to terminate. ...
      (Linux-Kernel)