Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

Defunct processes after fork()

andym297andym297 Member Posts: 3
Hi,

I have written a C program on Unix, which uses fork(), and it's doing something unexpected!!

The child process created handles an incoming connection to a socket, then exits, while the parent waits for another request. I've noticed though that a 'ps' command shows a set of processes called , one for each time a child has been created and exited.

Can anyone tell me how I can stop this, or if I even need to worry about it (If I kill the parent, all the processes disappear.

Thanks in advance.

Comments

  • abcabc Member Posts: 443
    : Hi,
    :
    : I have written a C program on Unix, which uses fork(), and it's doing something unexpected!!
    :
    : The child process created handles an incoming connection to a socket, then exits, while the parent waits for another request. I've noticed though that a 'ps' command shows a set of processes called , one for each time a child has been created and exited.
    :
    : Can anyone tell me how I can stop this, or if I even need to worry about it (If I kill the parent, all the processes disappear.
    :
    : Thanks in advance.
    :

    you need to either have the parent process ignore the SIGCLD signal or have it wait() or waitpid() for the children to die. Otherwise there remains some stuff for the parent to pick up (like the return value of the child) so the child shows up as in ps.
  • Andre YoungAndre Young USAMember Posts: 0

    _____ { http://forcoder.org } free ebooks and video tutorials about / Assembly Scratch MATLAB Go C Objective-C Python R Visual Basic PL/SQL Swift Java Visual Basic .NET PHP Delphi C# C++ JavaScript Perl Ruby Fortran Rust Erlang FoxPro Alice Awk Lua Prolog Scala ML Clojure LabVIEW Hack Lisp Dart SAS Logo ABAP Julia Transact-SQL F# Kotlin Crystal Ada VBScript COBOL Bash Scheme Apex D / __________

Sign In or Register to comment.