public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Felix von Leitner <leitner@convergence.de>
To: linux-kernel@vger.kernel.org
Subject: Off-Topic: how do I trace a PID over double-forks?
Date: Fri, 19 Jan 2001 01:36:49 +0100	[thread overview]
Message-ID: <20010119013649.A30163@convergence.de> (raw)

This is more a Unix API question than a Linux question.

I hope the issue is interesting enough to be of interest to some of you.

Basically, I am writing an init which features process watching
capabilities.  My init has a management channel with which you can tell
it "the PID of the ssh process is really 123 instead of 12".

When init forks a getty and that getty exits, it is restarted.  So far
so good.  But I want my init to be able to restart uncooperative
processes like sendmail that fork in the background.  sendmail may be a
bad example because the sources are available, but please imagine you
didn't have the sources to sendmail or didn't want to touch them.

Now, the back channel for my init has a function that allows to set the
PID of a process.  The idea is that the init does not start sendmail but
a wrapper.  The wrapper forks, runs sendmail, does some magic trickery
to find the real PID of the daemonized sendmail and tells init this PID
so init will know it has to restart sendmail when it exits and won't
restart the wrapper when that exits.

Follow me this far?  Great!  The real problem at hand is: what kind of
trickery can I employ in that wrapper.  I was hoping for something that
is not Linux specific, but I haven't found anything yet.  I was also
hoping that I could find a method that does not rely on /proc being
there or on any filesystem being mounted read-write (yes, my back
channel works if the filesystem is mounted read-only).  So, using
/proc and relying on something like /var/run/sendmail.pid are out.

Someone suggested using fcntl to create a lock and then use fcntl again
to see who holds the lock.  That sounded good at first, but fork() does
not seem to inherit locks.  Does anyone have another idea?

In case I made you wonder: http://www.fefe.de/minit/

Felix
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
Please read the FAQ at http://www.tux.org/lkml/

             reply	other threads:[~2001-01-19  0:38 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2001-01-19  0:36 Felix von Leitner [this message]
2001-01-20 10:55 ` Off-Topic: how do I trace a PID over double-forks? Eric Lammerts
  -- strict thread matches above, loose matches on Subject: below --
2001-01-21 17:47 Jesse Pollard
2001-01-21 17:54 ` Doug McNaught

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=20010119013649.A30163@convergence.de \
    --to=leitner@convergence.de \
    --cc=linux-kernel@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