[comp.sys.mac] HELP!!! MultiFinder EXPERT NEEDED!!!

lance@hermix.UUCP (Lance Ellinghouse) (12/01/89)

HELP!!!

We need to talk to someone that knows a lot about the internal 
workings of MultiFinder (In System 6.0.x)!!

PLEASE HELP!
Send E-mail or post how I can get in contact with you! (or someone you
know)

What we need is to ask MultiFinder if a program is still running..
Apple cannot tell me, and I cannot find the information anywhere..
PLEASE HELP!!


-- 
Lance Ellinghouse
Mark V Systems, Ltd.
UUCP: ...!hermix!lance
ARPA: hermix!lance@anes.ucla.edu

amanda@intercon.com (Amanda Walker) (12/02/89)

In article <328@hermix.UUCP>, lance@hermix.UUCP (Lance Ellinghouse) writes:
> We need to talk to someone that knows a lot about the internal 
> workings of MultiFinder (In System 6.0.x)!!
> 
> What we need is to ask MultiFinder if a program is still running..
> Apple cannot tell me, and I cannot find the information anywhere..
> PLEASE HELP!!

There is no sanctified way to do this.  However, the Autumn 1989 issue
of MacTech Quarterly (which should still be on the shelves) has an
article that goes over a lot of MultiFinder's undocumented calls,
including ones that will let you find out what applications are currently
running.

IF YOU USE THESE, THEY WILL PROBABLY BREAK SOON.

You could also take the cheap (and probably slightly more compatible)
route and just walk through the Apple menu looking for the name of the
application.  However, if your users rename it, you're out of luck.

--
Amanda Walker
InterCon Systems Corporation
amanda@intercon.com

goldman@apple.com (Phil Goldman) (12/02/89)

In article <328@hermix.UUCP> lance@hermix.UUCP (Lance Ellinghouse) writes:
> What we need is to ask MultiFinder if a program is still running..
> Apple cannot tell me, and I cannot find the information anywhere..

You certainly can do this, without even breaking.  However, it must be 
done with the help of an init.  You can simply patch some trap that is 
guaranteed to get called at Launch time, such as _OpenResFile(CurApName), 
and also patch _ExitToShell (after MF does).  With this, you can watch 
each and every app launch and quit.  It's not pretty, but it's simple and 
it works.

My views aren't necessarily Apple's, especially the part about never 
breaking.

-Phil Goldman

tim@hoptoad.uucp (Tim Maroney) (12/02/89)

In article <328@hermix.UUCP> lance@hermix.UUCP (Lance Ellinghouse) writes:
>What we need is to ask MultiFinder if a program is still running..
>Apple cannot tell me, and I cannot find the information anywhere..
>PLEASE HELP!!

It should be possible to do this cleanly in System 7.0.  In System
6.0.x, it's simple, but not totally clean.  Just look in the Apple
menu, using repeated GetItem calls, for the name of the application.
(You can tell when you get to the end of the menu by doing a
CountMItems.)  The item containing the application's name will go away
when the application quits.  This may break on future systems, but it
will continue to work on System 6.0.x for all time, so as long as you
do a SysEnvirons and check the system version before doing this, you're
cool.  Now send me a million dollars.  Thanks.
-- 
Tim Maroney, Mac Software Consultant, sun!hoptoad!tim, tim@toad.com

"I have recently been examining all the known superstitions of the world,
 and do not find in our particular superstition (Christianity) one redeeming
 feature.  They are all alike founded on fables and mythology."
    -- Thomas Jefferson

d88-jwa@nada.kth.se (Jon Watte) (12/02/89)

In article <1592@intercon.com> amanda@intercon.com (Amanda Walker) writes:

>You could also take the cheap (and probably slightly more compatible)
>route and just walk through the Apple menu looking for the name of the
>application.  However, if your users rename it, you're out of luck.

>Amanda Walker

What Amanda says almost always is sensible and well supported.
Only this time I have a mere question:

If you do a _Launch, you send the filename as argument, right ?
And while the _Launch-ed program runs, you can't rename it, right ?
So, if the program still runs - check for the name you _Launched in
the Apple menu (and pray to God that no DA has the same name ;-)

Now, how do you avoid the possibility that the user quits the
_Launch-ed application, and restarts it ? ... But that's maybe not
that big a chance (And I SUUUURE can tail-patch THIS trap - it SEEMS
so SAFE 8)

								h+
-- 
   --  Stay alert !  -  Trust noone !  -  Keep your laser handy !  ---
            h+@nada.kth.se  ==  h+@proxxi.se  ==  Jon Watte
                   longer .sig available on request

slosser@fugitive.berkeley.edu (Eric Slosser) (12/05/89)

Why bother asking Multifinder?  Set up a semaphor in the form of
a file.  Have the contents of the file be updated by the program
whose exsistence you wish to confirm.  Update the contents 
appropriately quickly.  The inquirer looks for the file, and
checks the contents.  If the first program crashes, the contents 
won't be current (I suggest the contents reflect the system time).
If the first program exits normally, it should delete the file.

You can do all the tricky stuff you want with walking the DA menu,
deciphering MF internals, patching traps, but you'd only be shooting
yourself in the foot (as acknowledged by those who offered these
approaches)

Please note, if the file is accessible over the network, then 
you could easily (depending on which network, of course) 
check to see if a program is running on another machine.

Even if that machine is an IBM-pc.

(I don't read news often, so it's better to send (e)mail)
Eric Slosser, SciComp Software, 
2912 Claremont Ave, #21 Berkeley CA 94705 

slosser@fugitive.berkeley.edu (Eric Slosser) (12/06/89)

Newsgroups: comp.sys.mac.programmer,comp.sys.mac
Subject: Re: HELP!!! MultiFinder EXPERT NEEDED!!!
Summary: 
Expires: 
References: <328@hermix.UUCP> <9161@hoptoad.uucp>
Sender: 
Reply-To: slosser@fugitive.UUCP (Eric Slosser)
Followup-To: 
Distribution: 
Organization: /etc/organization
Keywords: 

You want one program to know if another is running? 

Why bother asking Multifinder?  Set up a semaphor in the form of
a file.  Have the contents of the file be updated by the program
whose exsistence you wish to confirm.  Update the contents 
appropriately quickly.  The inquirer looks for the file, and
checks the contents.  If the first program crashes, the contents 
won't be current (I suggest the contents reflect the system time).
If the first program exits normally, it should delete the file.

You can do all the tricky stuff you want with walking the DA menu,
deciphering MF internals, patching traps, but you'd only be shooting
yourself in the foot (as acknowledged by those who offered these
approaches)

Please note, if the file is accessible over the network, then 
you could easily (depending on which network, of course) 
check to see if a program is running on another machine.

The other way I'd do it, if the queried program wasn't written
to play with a file in the above way, is to walk the chain of 
open files, looking for one of type APPL, and creator 'whatever'.

Look in IM-4 for the calls.  This way uses approved traps, so is
also less likely to break.

Have fun.

(I don't read news often, so it's better to send (e)mail)
Eric Slosser