🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.unix.programmer
Article #154

Re: help with unexec

#154
From: Oliver Laumann
Date: Tue, 28 Jul 1992 10:05
35 lines
2342 bytes
dnicodem@cs.ulowell.edu (David Nicodemus) writes:
> I am looking for a way to force a program out of execution, and save an
> image of the program that can be restarted from the same point at a later
> time. 
> 
> It appears that the gnu unexec() function from gnu emacs will do this;
> however, the last parameter asks for a "starting address." 
> 
> How can I find this "starting address" (which I want to be the current
> point of execution)?  Is this even possible?

I'm not sure I understand what exactly you want to accomplish.  You
certainly cannot *force* a program to dump its image to disk using
unexec(); the program must call unexec() voluntarily.

The entry point you can supply to unexec() is the address where the
a.out file produced by unexec() will start when it is invoked later.
Every a.out file has an entry point; it's part of the a.out header.

Anyway, when using unexec(), you cannot have the newly created a.out
file resume execution at the point where the original invocation saved
its image.  To be able to do this, unexec() would have to save not only
the text and data segment of the running program, but also the entire
execution state (stack and registers).

The `Elk' Scheme interpreter (export.lcs.mit.edu:contrib/elk-1.5a.tar.Z)
does have the function which you seem to be looking for; it is named
`dump'.  `dump' creates an a.out file which, when invoked, causes the
invocation of `dump' that created this file to return.  In this case,
the return value of `dump' is true, while it returns false in the
original invocation of the program (not unlike the fork() system call).

However, the functionality of `dump' is based on Scheme's continuations;
so it's probably of little or no use without the rest of the Scheme
interpreter.
Technical Details
Message-ID: <1992Jul28.100513.29858@cs.tu-berlin.de>
Path: arc1-ca.pugleaf.net!sparky!uunet!darwin.sura.net!jvnc.net!yale.edu!ira.uka.de!math.fu-berlin.de!zrz.tu-berlin.de!cs.tu-berlin.de!net
References: <1992Jul28.014955.21272@ulowell.ulowell.edu>

Show Full Headers
Complete Article Headers
Newsgroups: comp.unix.programmer,comp.unix.questions,gnu.misc.discuss,gnu.gcc.help,comp.unix.ultrix
Path: arc1-ca.pugleaf.net!sparky!uunet!darwin.sura.net!jvnc.net!yale.edu!ira.uka.de!math.fu-berlin.de!zrz.tu-berlin.de!cs.tu-berlin.de!net
From: net@cs.tu-berlin.de (Oliver Laumann)
Subject: Re: help with unexec
Message-ID: <1992Jul28.100513.29858@cs.tu-berlin.de>
Sender: news@cs.tu-berlin.de
Organization: Technical University of Berlin, Germany
References: <1992Jul28.014955.21272@ulowell.ulowell.edu>
Date: Tue, 28 Jul 1992 10:05:13 GMT
Lines: 35