public inbox for systemtap@sourceware.org
 help / color / mirror / Atom feed
From: "jistone at redhat dot com" <sourceware-bugzilla@sourceware.org>
To: systemtap@sources.redhat.com
Subject: [Bug tapsets/9925] task_execname(task) incorrect in process.create
Date: Fri, 06 Mar 2009 01:28:00 -0000	[thread overview]
Message-ID: <20090305173231.2145.qmail@sourceware.org> (raw)
In-Reply-To: <20090305162902.9925.cap@nsc.liu.se>


------- Additional Comments From jistone at redhat dot com  2009-03-05 17:32 -------
(In reply to comment #3)
> It may be expected (given what process.create really is) but it is not
> "correct". That however can be fixed by updating the documentation...
> 
> The "task" in process.create is half the new process and half the old. I fear
> this will confuse people even if the documentation/manpage is updated.

It is as correct as we can be with the way Linux defines processes.

When a process calls fork(), a new process is created as an exact copy of the
old.  This is not half-anything -- it is a real bash process with a new PID. 
Then when the process calls exec(), that process starts running in a new
executable without changing PIDs.  From the kernel perspective, this is not a
new process at all.

From a user perspective, the completed combination of fork-exec represents a new
process, which is probably why you say it's half-done.  However, there's nothing
that says that fork and exec must happen back-to-back.  In general, fork and
exec can be called independently at any time.

For example, a daemon might be idle listening for incoming connections.  When a
connection comes in, it calls fork.  The new PID from the fork will handle the
request, while the old PID goes back to listening for other connections.  In
this case, you have a fork creating a new process, without ever having an exec.

You may also have execs without a fork.  Consider a command like "sudo ls".  The
process flow will look something like:

  pid-1 bash calls fork -> creates pid-2 bash
  pid-2 bash calls exec -> becomes pid-2 sudo
  (sudo changes the user id to root)
  pid-2 sudo calls exec -> becomes pid-2 ls

So many different combinations of fork/exec can occur...

-- 


http://sourceware.org/bugzilla/show_bug.cgi?id=9925

------- You are receiving this mail because: -------
You are the assignee for the bug, or are watching the assignee.

  parent reply	other threads:[~2009-03-05 17:32 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-03-05 17:02 [Bug tapsets/9925] New: " cap at nsc dot liu dot se
2009-03-05 17:05 ` [Bug tapsets/9925] " mjw at redhat dot com
2009-03-05 17:22 ` cap at nsc dot liu dot se
2009-03-05 17:32 ` cap at nsc dot liu dot se
2009-03-05 17:37 ` dsmith at redhat dot com
2009-03-06  1:28 ` jistone at redhat dot com [this message]
2009-03-06  8:19 ` jistone at redhat dot com
2009-03-06  9:18 ` wenji dot huang at oracle dot com
2009-03-06 14:18 ` cap at nsc dot liu dot se
2009-03-06 14:27 ` dsmith at redhat dot com
2009-03-15 16:44 ` jistone at redhat dot com

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=20090305173231.2145.qmail@sourceware.org \
    --to=sourceware-bugzilla@sourceware.org \
    --cc=systemtap@sources.redhat.com \
    /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 read-only IMAP folder(s) and NNTP newsgroup(s).