Re: Guaranteed Term Restore w/ atexit(3) No Good

From: Barry Margolin (barmar_at_alum.mit.edu)
Date: 08/31/05

  • Next message: Henry Townsend: "Re: libdl/glibc question"
    Date: Wed, 31 Aug 2005 00:23:01 -0400
    
    

    In article <Pine.SOL.4.58.0508300919000.12892@zen.rite-group.com>,
     Rich Teer <rich.teer@rite-group.com> wrote:

    > On Tue, 30 Aug 2005, Michael B Allen wrote:
    >
    > > Can someone suggest an alternative method to ensure that
    > > "tcsetattr(STDIN_FILENO, TCSANOW, &restore);" is called when only the
    > > parent process exits?
    >
    > Not a particularly clever way, but how about making note of your
    > PID in the parent and then checking your PID in your exit handler,
    > calling tcsetattr only when getpid() == saved_parent_pid?

    A common technique is to call exit() only in the parent process, and
    _exit() in the children.

    -- 
    Barry Margolin, barmar@alum.mit.edu
    Arlington, MA
    *** PLEASE post questions in newsgroups, not directly to me ***
    

  • Next message: Henry Townsend: "Re: libdl/glibc question"

    Relevant Pages

    • Re: Why doesnt kill work?
      ... >> with out sending the exit code to the child process. ... Killing the parent process will always get rid of any ... This status information, which primarily includes an exit code, ... > remembering those few status bytes, the zombie process entry stays ...
      (Fedora)
    • Re: [opensuse] openSUSE 10.2 - process mono defunct
      ... it so confused that can't die cleanly and turns zombie. ... and whose parent process is still running but has not issued a wait ... system call to retrieve its child's exit status. ... Init _always_ reaps its children or descendants. ...
      (SuSE)
    • Re: unix shell script ignores exit when in function that is piped to tee
      ... > Script ignores 'exit' when called from within a function that is ... echo THIS SHOULDNT SHOW UP BECAUSE SUBSHELL HAS EXITED ... of the command to be executed in a child process, and the stdout of that child ... process is fed into the stdin of the parent process that's running the right ...
      (comp.unix.shell)
    • Re: Ensuring parent/child processes
      ... approved way of forking involves the parent process _just_ managing ... Memory constraints mean I would like one parent and one child both to ... child or the parent die unexpectedly, ... print "About to exit inside unless\n"; ...
      (comp.lang.perl.misc)
    • Re: A tricky problem about Process.wait and popen
      ... signal of child process exit sent to parent process will lost. ... It's not a bug. ...
      (comp.lang.ruby)