public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Dan Sturtevant <sturtx@gmail.com>
To: Pjotr Kourzanov <peter.kourzanov@xs4all.nl>
Cc: linux-kernel@vger.kernel.org
Subject: Re: fork/clone external to a process?
Date: Tue, 21 Dec 2004 19:36:18 -0500	[thread overview]
Message-ID: <7d92433304122116361c2933fb@mail.gmail.com> (raw)
In-Reply-To: <41C8B128.7010201@xs4all.nl>

> > Hi,
> >
> > Is there any clean way to fork a process from outside the process itself?
> >
> > I'm running a commercial application that I only have a binary copy
> > of.  All the usual Posix fork stuff only works from inside the running
> > process.
> 
>    Have you tried playing with LD_PRELOAD (libc.so hack)?
> 

What I'm really looking to do is "checkpoint" the process.  If I were
inside the process, I'd fork off a child and call wait() in the
parent.  When I wanted to "revert" i'd kill off the child, which would
return from the parent's wait().  I'm trying to do this to VMware. 
Because a forked child shares all the open file descriptors with its
parent, they should be able to share the gui so long as only either
the parent or child are awake at the same time.

I have allready modified the Bochs emulator and gotten it to do this,
but I could just use fork the normal way inside the executable since
it's an open source project.

(Yes, I know VMware allready has checkpoint/revert stuff and I don't
need this crazy stuff to use it.  I'm trying to do wierd stuff under
VMware however.)

Ideally, i'd have some kind of wierd system call like:
childpid = wierd_external_fork(parentpid);

int wierd_external_fork(int parentpid)
{
  int childpid;
  wierd_sigstop_and_wait(parentpid);
  childpid = wierd_copy_process_state(parentpid);  //keep controling terminal?
  return childpid;
}

I think I understand what you're saying about using LD_PRELOAD to
hijack a function call in a shared object.  I could do this and try to
slip a call to fork() into the executable by substituting a function
and thus do this the normal way.

My problem is that I want this to happen on demand rather than
whenever the substituted shared library call is invoked inside the
executable.

I haven't messed around with LD_PRELOAD before.  Am I interpreting
everything correctly here or am I way off base?

Feel free to tell me that I'm smoking crack.

Thanks for the help.

  reply	other threads:[~2004-12-22  0:36 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2004-12-21 15:49 fork/clone external to a process? Dan Sturtevant
2004-12-21 23:26 ` Pjotr Kourzanov
2004-12-22  0:36   ` Dan Sturtevant [this message]
     [not found]     ` <41C936AF.7060707@xs4all.nl>
2004-12-22 13:50       ` Dan Sturtevant
2004-12-25 22:26     ` Pavel Machek
2005-02-24  0:01       ` Dan Sturtevant

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=7d92433304122116361c2933fb@mail.gmail.com \
    --to=sturtx@gmail.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=peter.kourzanov@xs4all.nl \
    /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