Opened 17 years ago

Last modified 9 years ago

#198 new defect

[ATLAS] SIGINT, SIGTERM are ignored

Reported by: Philip Taylor Owned by:
Priority: Should Have Milestone: Backlog
Component: Atlas editor Keywords:
Cc: Patch:

Description

When sending SIGINT/SIGTERM (e.g. with ctrl+c in the console, or via kill) to the game process on Linux, while the Atlas UI is loaded, nothing happens. It ought to terminate the process (like it does when the UI isn't running).

Attachments (1)

fix-sigint+term.patch (3.5 KB ) - added by Markus 11 years ago.
open file dialog should work, the others still block

Download all attachments as: .zip

Change History (22)

comment:1 by (none), 14 years ago

Milestone: ASAP

Milestone ASAP deleted

comment:2 by Andrew, 14 years ago

Milestone: Backlog

comment:3 by Markus, 11 years ago

The signals are caught by SDL and there is a SDL_QUIT in GameLoop.cpp:L219. But thats not handled to actually quit the application.

I experimented a bit to get the application to actually quit like closing the window but there may be a simpler solution.

Resetting the signal handler would also work, but that forces the application to quit. No cleaning up is performed.

Last edited 11 years ago by Markus (previous) (diff)

comment:4 by Markus, 11 years ago

Keywords: patch added
Milestone: BacklogAlpha 15
Summary: SIGINT, SIGTERM are ignored[PATCH] SIGINT, SIGTERM are ignored

comment:5 by historic_bruno, 11 years ago

Keywords: review added

comment:6 by Markus, 11 years ago

I dont actually think, that patch should be commited. Its just to show how it could be done. I really hope someone with more wx* experience can solve this more correct and elegant.

comment:7 by historic_bruno, 11 years ago

Owner: changed from Philip Taylor to Markus

comment:8 by historic_bruno, 11 years ago

Your patch works and it doesn't seem like too bad of a solution. The only thing I could think of was using this to close the top window/frame:

wxTheApp->GetTopWindow()->Close(true);

might be nicer than faking the close event, but that doesn't work and I don't know why :(

Last edited 11 years ago by historic_bruno (previous) (diff)

comment:9 by Markus, 11 years ago

Yes I too tried some things. The call to Close would be nice. But some other things as well either didnt quit the program or made it crash. I could imagine that the multithreading is the problem. (We want to close the main window from a seperate thread.)

Btw, is this working/needed on other platforms?

comment:10 by historic_bruno, 11 years ago

I don't think it's necessary on Windows, but it should fix the same problem on OS X (then again that depends on the SDL implementation, so I will test to make sure).

Looks like wxPostEvent() is the correct way of sending the event to a different thread (in 2.8), they've added wxQueueEvent() to 2.9 for events that have strings in them, but wxCloseEvent doesn't and we can't rely on 2.9 anyway, so in fact, I think you found the only good way of doing this :)

comment:11 by historic_bruno, 11 years ago

Well there is a slight issue with the patch, try opening a file dialog, then use Ctrl+C to close Atlas. On wxGTK 2.8 / Ubuntu 12.04, everything closes except the dialog, which blocks the process from terminating.

comment:12 by historic_bruno, 11 years ago

One other comment: Atlas_End should be called Atlas_CloseWindow instead.

comment:13 by historic_bruno, 11 years ago

Keywords: review removed

comment:14 by Markus, 11 years ago

The problem with the file dialog exists for all dialogs inherting from wxDialog (wxFileDialog, wxColourDialog, ...). They are not added as children to the main window, so I dont know how I could get a handle to them.

Keeping an own list of currently open dialogs seems a bad idea. I tried it for the open file dialog but it is needed to wait for the dialog to actually close before we send the next close request to the main window. (Not doing so will cause a segv, perhaps due to threading and the main window being destroyed while the OnOpen handler is still executed.)

by Markus, 11 years ago

Attachment: fix-sigint+term.patch added

open file dialog should work, the others still block

comment:15 by Markus, 11 years ago

Keywords: review added

comment:16 by historic_bruno, 11 years ago

Hmm, yeah I don't really like that solution, it would have to work for all dialogs but that seems like a hack anyway. (BTW I think it would be better to leave old patches up, so we can see what was discussed before, instead of replacing them)

comment:17 by Jorma Rebane, 11 years ago

Keywords: review removed

In general terms you can just call the C library function "exit(0);" to quit the process.

There is no need to do any resource cleanup, because the Operating System will ensure that all memory mapped by the process is unmapped and any file handles are released.

As I understand, the SDL event SDL_QUIT only happens if an external process, the user, or the OS requests termination. So in that case it's not a normal exit anyways and we can get away with simple exit(0);

As for where to call it: The main input handler in main.cpp would be the correct place where to call exit(), not the actual event loop.

comment:18 by historic_bruno, 10 years ago

Milestone: Alpha 15Backlog

comment:19 by historic_bruno, 10 years ago

Owner: Markus removed

comment:20 by Stan, 9 years ago

Keywords: patch removed
Summary: [PATCH] SIGINT, SIGTERM are ignoredSIGINT, SIGTERM are ignored

comment:21 by Stan, 9 years ago

Summary: SIGINT, SIGTERM are ignored[ATLAS] SIGINT, SIGTERM are ignored
Note: See TracTickets for help on using tickets.