linux-assembly.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Ricardo Nabinger Sanchez <rnsanchez@terra.com.br>
To: linux-assembly@vger.kernel.org
Subject: Re: sys_fork
Date: Tue, 29 Nov 2005 22:20:13 -0200	[thread overview]
Message-ID: <20051129222013.305cd393.rnsanchez@terra.com.br> (raw)
In-Reply-To: <200511291857.40019.hitoc_mail@yahoo.it>

Quoting  HIToC <hitoc_mail@yahoo.it>
Sent on  Tue, 29 Nov 2005 19:59:56 +0100

Hello,

> Yes, the problem was that I do not considered the value in EAX!
> A possible solution to free system resources used by chlid, is to call
> sys_waitpid with argument pid setted to 0 and waiting until the
> value returned in EAX is greater than 0...
> Now I understand some more thing over the fork system call!!

that's nice, have you studied man 2 fork already? :)

I wouldn't recommend you to call wait4pid, because your process (the accept
() one) will block, and thus fork() will not be an advantage (you can do
that naturally without forking).

What would be a nice thing to do is to prepare a signal handler for
SIG_CHILD, to clean up its children.  It is very single to use, all you
need is to tell the kernel to use your custom function for handling
SIG_CHILD, instead of the default action (which is to ignore the signal,
and you'll end with a bunch of zombies).

Btw, such a function is like this in C:

void handle_sigchild() {
	wait();
}

notice that the process will not block, as the signal is being delivered
because of a terminating child.  it will be cleaned even if the process is
blocked in accept().

I'm almost sure that you'll also need to handle interrupted accept(), which
will return -1 and errno will have EINTR (interrupted system call).  in
this case, call accept() again :)

have fun :)

-- 
Ricardo Nabinger Sanchez
GNU/Linux #140696 [http://counter.li.org]
Slackware Linux + FreeBSD

  Left to themselves, things tend to go from bad to worse.

  reply	other threads:[~2005-11-30  0:20 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2005-11-26 17:06 sys_fork HIToC
2005-11-26 17:23 ` sys_fork Ricardo Nabinger Sanchez
2005-11-26 19:26 ` sys_fork Claudio Fontana
2005-11-27 18:22   ` sys_fork HIToC
2005-11-27 19:27     ` sys_fork Ricardo Nabinger Sanchez
2005-11-28 10:10       ` sys_fork HIToC
2005-11-28 13:48         ` sys_fork Frank Kotler
2005-11-28 19:25         ` sys_fork Ricardo Nabinger Sanchez
2005-11-29 18:59           ` sys_fork HIToC
2005-11-30  0:20             ` Ricardo Nabinger Sanchez [this message]
2005-11-30  4:00               ` sys_fork Robert Plantz
2005-11-30 10:26                 ` sys_fork Ricardo Nabinger Sanchez

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20051129222013.305cd393.rnsanchez@terra.com.br \
    --to=rnsanchez@terra.com.br \
    --cc=linux-assembly@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).