Re: fork/clone external to a process?

From: Dan Sturtevant
Date: Tue Dec 21 2004 - 19:39:26 EST

> > 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 ( 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;
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

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.
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at
Please read the FAQ at