[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Graceful termination again
Re: Graceful termination again
Tue, 24 Jan 2006 03:35:00 +0200
On 2006-01-23 15:05:41 +0200 Richard Frith-Macdonald <address@hidden> wrote:
On 23 Jan 2006, at 08:50, Roman Belenov wrote:
I hacked a bit trying to implement logoff with graceful application
termination on GNUstep and got some questions:
1) How to get a list of all running GNUstep applications ?
launchedApplications seems to return only the list of apps launched from the
current one. For now I just use a list of message ports obtained by examining
corresponding subdirectory and treat everythying as a proxy for application.
Well, the way workspace operations generally *should* work as I understand
it, is that they should contact the workspace manager application and ask it
to do the job for them. There is partial support for this in the
NSWorkspace class, but it has never been completed. Basically, the idea is
that the local NSWorkspace instance should first try to ask the workspace
manager application to do jobs, and if no application is found, it should do
the best it can. In the case of launched tasks, this means that every
application keeps track of any tasks it sees being launched, but since there
is no workspace application launching all tasks, there is no central
repository of all the information.
So, what you should ideally be doing is fixing that ...
Problem is that it was never completed because to make it useful there needs
to be a workspace manager application and when I wrote it no such
application existed. Then later Enrico wrote GWorkspace without much
attention to integration with the NSWorkspace class, and we never got
together to make it all work.
I've always thought that the NSWorkspace class *implies* the existence of a Workspace
application; it is sufficient to read some method declarations to understand this. (and,
probably, it implies also the fact that the Workspace application coincides with the
For this reason, I have had already proposed an "integration" of GWorkspace
with the NSWorkspace class five or six years ago but my app was just at its beginning
(and very buggy) and I received a big NO from the GNUstep mainteners :-)
After some years the _workspaceApplication method has been added to NSWorkspace
with GWorkspace as default but, in the meantime, GWorkspace had gone its way
without (mea culpa) too much attention for the NSWorkspace class; only some of
the methods that NSWorkspace could use have been implemented; for example:
-selectFile:inFileViewerRootedAtPath: exists but _launchApplication:arguments:
That being said, I can implement in GWorkspace all we want, if we think that
this is the right way, but I'd want to propose something else. Perhaps some of
the older gnusteppers remember this:
"The Zen of no UI
Why don't we just write a GNU-DO based WorkspaceMaster which could perform all the
necessary tasks like copying files, killing apps, checking for removable media etc.
pp. and then just use the NSWorkspace class plus some new notifications to handle
the workspace task?"
In other words: I want to re-propose a "workspace" daemon that implements all
the NSWorkspace methods that imply distributed information, leaving all the other things
to the normal NSWorkspace instance.
With this solution, the need of the _workspaceApplication method would remain,
but only for those (one or two) methods that require user interaction for
confirmation or in case of error as -performFileOperation:::::. The daemon
could anyway have a default implementation that, or does nothing, or perform
the operation without asking the user.
Moreover, I think that it can be written very easily copying from the gdnc and
2) What is the correct way to check the result of sending terminate to
application (from another one) ? Experiments show that if application
terminates, I get an exception caused by connection timeout.
Yes .. you expect the connection to go away when the app terminates. I
don't think there is any realistic way you can be absolutely sure an app has
completely gone away (though you could try registering a port using the name
of the task ... if it works then the app has gone ... if it fails either the
app is still running or another app with the same name has started). It's
probably best to just assume that loss of the connection to the app means
that it has died.
Of course, in the case of the workspace manager application (which should
generally have launched the app and be responsible for shutting it down
too), you have an NSTask object corresponding to the launched application,
so you can check the NSTask instance to see if the application is still
running after it has been told to terminate.
Gnustep-dev mailing list
Re: Graceful termination again, Chris B. Vetter, 2006/01/23