* fork/clone external to a process?
@ 2004-12-21 15:49 Dan Sturtevant
2004-12-21 23:26 ` Pjotr Kourzanov
0 siblings, 1 reply; 6+ messages in thread
From: Dan Sturtevant @ 2004-12-21 15:49 UTC (permalink / raw)
To: linux-kernel
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.
Is there any reason it's not possible to do so? Obviously threading
and file desciptors open a whole can of worms, but in the base case,
is it possible?
Thanks in advance, and sorry if it's a stupid question.
Dan Sturtevant
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: fork/clone external to a process?
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
0 siblings, 1 reply; 6+ messages in thread
From: Pjotr Kourzanov @ 2004-12-21 23:26 UTC (permalink / raw)
To: Dan Sturtevant; +Cc: linux-kernel
Dan Sturtevant wrote:
> 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)?
>
> Is there any reason it's not possible to do so? Obviously threading
> and file desciptors open a whole can of worms, but in the base case,
> is it possible?
>
> Thanks in advance, and sorry if it's a stupid question.
>
> Dan Sturtevant
> -
> To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at http://vger.kernel.org/majordomo-info.html
> Please read the FAQ at http://www.tux.org/lkml/
>
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: fork/clone external to a process?
2004-12-21 23:26 ` Pjotr Kourzanov
@ 2004-12-22 0:36 ` Dan Sturtevant
[not found] ` <41C936AF.7060707@xs4all.nl>
2004-12-25 22:26 ` Pavel Machek
0 siblings, 2 replies; 6+ messages in thread
From: Dan Sturtevant @ 2004-12-22 0:36 UTC (permalink / raw)
To: Pjotr Kourzanov; +Cc: linux-kernel
> > 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.
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: fork/clone external to a process?
[not found] ` <41C936AF.7060707@xs4all.nl>
@ 2004-12-22 13:50 ` Dan Sturtevant
0 siblings, 0 replies; 6+ messages in thread
From: Dan Sturtevant @ 2004-12-22 13:50 UTC (permalink / raw)
To: Pjotr Kourzanov, linux-kernel
On Wed, 22 Dec 2004 09:56:15 +0100, Pjotr Kourzanov
<peter.kourzanov@xs4all.nl> wrote:
>
> What exactly are you referring to by "checkpoint" and "revert"? Do
> you mean temporarily stop and then resume?
>
Checkpoint is a terrible name for what I want to do to the process.
The only thing I mean is that I want one of the "forked" processes
either wait() ing for the other one to end or SIGSTOPed so I can wake
it up when the other ends. The sleeping one will be in the state that
the other was in at the time of the fork.
> Well, the kernel AFAIK makes deep copies of task structs only on
> behalf of a process (would be a security hole otherwise). I suppose you
> could change that, but I am afraid there will be a lot of resistance to
> it on LKML...
>
I would never suggest anyone else do this to a kernel they care deeply about.
> >
> > My problem is that I want this to happen on demand rather than
> > whenever the substituted shared library call is invoked inside the
> > executable.
> >
>
> Do you really need /that/ flexibility? Just strace vmware and see
> what calls it does and when. Then just pick one that's in libc.so or
> another shared library. Don't forget to pass the call down to the
> original function;-)
I guess LD_PRELOAD could work. It would be especially nice if I could
get inside a signal handler.
Thanks Pjotr
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: fork/clone external to a process?
2004-12-22 0:36 ` Dan Sturtevant
[not found] ` <41C936AF.7060707@xs4all.nl>
@ 2004-12-25 22:26 ` Pavel Machek
2005-02-24 0:01 ` Dan Sturtevant
1 sibling, 1 reply; 6+ messages in thread
From: Pavel Machek @ 2004-12-25 22:26 UTC (permalink / raw)
To: Dan Sturtevant; +Cc: Pjotr Kourzanov, linux-kernel
Hi!
> 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?
gdb attach the vmware, then force it to call routine you preloaded...
Or look at subterfugue.
Pavel
--
People were complaining that M$ turns users into beta-testers...
...jr ghea gurz vagb qrirybcref, naq gurl frrz gb yvxr vg gung jnl!
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: fork/clone external to a process?
2004-12-25 22:26 ` Pavel Machek
@ 2005-02-24 0:01 ` Dan Sturtevant
0 siblings, 0 replies; 6+ messages in thread
From: Dan Sturtevant @ 2005-02-24 0:01 UTC (permalink / raw)
To: Pavel Machek; +Cc: linux-kernel
> gdb attach the vmware, then force it to call routine you preloaded...
>
> Or look at subterfugue.
> Pavel
Brilliant Pavel. Thank you. gdb works great.
Dan
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2005-02-24 0:16 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
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
[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
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox