[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Terminate NSApp gracefully when receiving SIGNIT. )Fwd: [Etoile-disc
From: |
Yen-Ju Chen |
Subject: |
Re: Terminate NSApp gracefully when receiving SIGNIT. )Fwd: [Etoile-discuss] Etoile 0.2 on Solaris) |
Date: |
Wed, 1 Aug 2007 15:11:53 -0700 |
On 8/1/07, Fred Kiefer <fredkiefer@gmx.de> wrote:
> I like the idea of responding to signals properly, but checking for
> unistd.h and then including signal.h is clearly wrong. When we add
> something, we need to add it the clean way.
>
> And actually we already have this code in place. In back we have for x11
> a very similar call to signal:
>
> signal(SIGTERM, terminate);
>
> and terminate() is of course:
>
> static void
> terminate(int sig)
> {
> [NSApp terminate: NSApp];
> }
>
> Now we only need to decide if we think that SIGINT should be handled the
> same as SIGTERM. And if so add one line to XGServer.m
The idea was to receive a signal when users logout x window.
The SIGINT is normally triggered ty Ctrl-C.
I am not sure whether it depends on the platform for logout.
Yen-Ju
>
> Cheers,
> Fred
>
> Yen-Ju Chen wrote:
> > Hi,
> >
> > Here is a patch from David to terminate NSApp gracefully
> > when an application receive a SIGINT signal.
> > It is what NSApp on Cocoa behaves.
> > So it is nice to have it in GNUstep.
> >
> > Thanx.
> >
> > Yen-Ju
> >
> > ---------- Forwarded message ----------
> > From: David Chisnall <theraven@sucs.org>
> > Date: Jul 31, 2007 5:12 PM
> > Subject: Re: [Etoile-discuss] Etoile 0.2 on Solaris
> > To: Discussion list for Étoilé desktop environment <etoile-discuss@gna.org>
> >
> >
> > On 1 Aug 2007, at 00:37, Yen-Ju Chen wrote:
> >
> >> Maybe we should file a feature request to GNUstep ?
> >
> > Or I could just implement it. Here's the diff, let me know if you
> > have any problems (if there aren't any, can someone push it upstream;
> > the FSF now have my copyright assignment form):
> >
> > *** NSApplication.m.original Tue Jul 3 19:21:11 2007
> > --- NSApplication.m Wed Aug 1 01:09:50 2007
> > ***************
> > *** 31,36 ****
> > --- 31,39 ----
> >
> > #include "config.h"
> > #include <stdio.h>
> > + #ifdef HAVE_UNISTD_H
> > + #include <signal.h>
> > + #endif //HAVE_UNISTD_H
> >
> > #include <Foundation/NSArray.h>
> > #include <Foundation/NSAutoreleasePool.h>
> > ***************
> > *** 95,100 ****
> > --- 98,113 ----
> > static NSUncaughtExceptionHandler *defaultUncaughtExceptionHandler;
> >
> > /*
> > + * Terminate cleanly if instructed.
> > + */
> > + #ifdef HAVE_UNISTD_H
> > + void terminateApp(int sig)
> > + {
> > + [NSApp terminate:nil];
> > + }
> > + #endif //HAVE_UNISTD_H
> > +
> > + /*
> > * Gui library user friendly exception handler
> > */
> > static void
> > ***************
> > *** 455,460 ****
> > --- 468,476 ----
> > tileCell = [[NSCell alloc] initImageCell: tileImage];
> > RELEASE(tileImage);
> > [tileCell setBordered: NO];
> > + #ifdef HAVE_UNISTD_H
> > + signal(SIGINT, terminateApp);
> > + #endif //HAVE_UNISTD_H
> > }
> >
> > - (BOOL) acceptsFirstMouse: (NSEvent*)theEvent
> >
> > _______________________________________________
> > Etoile-discuss mailing list
> > Etoile-discuss@gna.org
> > https://mail.gna.org/listinfo/etoile-discuss
> >
> >
> > _______________________________________________
> > Discuss-gnustep mailing list
> > Discuss-gnustep@gnu.org
> > http://lists.gnu.org/mailman/listinfo/discuss-gnustep
> >
>
>