Welcome, Guest. Please login or register.

Author Topic: Ctrl-C handling issues  (Read 7419 times)

Description:

0 Members and 2 Guests are viewing this topic.

Offline MinuousTopic starter

Ctrl-C handling issues
« on: June 11, 2011, 03:35:32 PM »
The following well-known code is supposed to disable SAS/C Ctrl-C handling:

int  CXBRK(void) { return 0; } /* Disable SAS/C Ctrl-C handling */
void chkabort(void) { ; } /* really */

But it does not seem to work, even when using a SCOPTIONS file containing NOCHECKABORT. My program (AmiArcadia 16.02) checks for Ctrl-C in its console window via SetSignal(). Most of the time it catches these, but sometimes it seems SAS/C's break handler catches it instead, and I get a "** User Abort Requested **" requester with option "CONTINUE" and "ABORT", Abort will shut down the program without closing the window etc, Continue lets the program continue and the Ctrl-C is ignored (my break handler doesn't catch it). This code seems to be inserted by SAS/C, as the relevant text string is embedded in the executable.

So, the question is: why isn't SAS/C's break handling turned off, and how can I do this?

Interesting, the OS4 version which is compiled with GCC apparently has a similar issue.
 

Offline MinuousTopic starter

Re: Ctrl-C handling issues
« Reply #1 on: June 11, 2011, 05:29:57 PM »
>Does your program have multiple tasks?

No.

>Is it started from Workbench, or is the break signal sent via CLI?

It can be started from either, but to reproduce the problem I start it from Workbench and then it auto-opens the CLI window on its first printf().

>are all your units of compilation (i.e. before linking) share the same definitions of chkabort and CXBRK?

No, just one definition for the whole program. I will try a separate definition in each module and see if that helps.
 

Offline MinuousTopic starter

Re: Ctrl-C handling issues
« Reply #2 on: June 11, 2011, 05:31:07 PM »
>Does your program have multiple tasks?

No.

>Is it started from Workbench, or is the break signal sent via CLI?

It can be started from either, but to reproduce the problem I start it from Workbench and then it auto-opens the CLI window on its first printf().

>are all your units of compilation (i.e. before linking) share the same definitions of chkabort and CXBRK?

No, just one definition for the whole program. If I try separate definitions in each module the linker complains about multiply defined symbols.
 

Offline MinuousTopic starter

Re: Ctrl-C handling issues
« Reply #3 on: June 12, 2011, 08:36:15 AM »
That doesn't work either. chkabort() is defined in sc:include/dos.h as not returning anything, so making the suggested change causes a "conflict with previous declaration" error.

So I edited sc:include/dos.h to indicate that it returns an int. Now it compiles OK again but the resulting program still has the same problem.
« Last Edit: June 12, 2011, 11:41:06 AM by Minuous »
 

Offline MinuousTopic starter

Re: Ctrl-C handling issues
« Reply #4 on: June 16, 2011, 06:46:01 AM »
@x303:

>Btw I thought you developed AA with Stormc (looking at the code). Why bother with sas/c ???

No, the release builds are built with SAS/C. In theory it is supposed to be compilable with StormC but I have not tried this with any recent version. IIRC I ran into some StormC code generation bugs. Report+ and Handy are built with StormC but the rest of my software is built with SAS/C.

>Ran the latest version of it (16.02) and found no problem with CTRL-C. It says 'Quitting.' and exits the program normally.

The actual scenario to reproduce the behaviour is this: Start AmiArcadia from WB. Switch to Galaxia. Turn on "Log inefficient code". Activate the resulting console window. Press Ctrl-C. About three-quarters of the time it says "Quitting" and quits cleanly, the other quarter of the time it is getting intercepted by SAS/C and the "** User Abort Requested **" comes up.

@Ismart/ChaosLord:

>Are you using your own startup code?

No.

>I propose that ur prob is caused by: you have some sort of nonstandard Shell or Console device installed. Or you have some evil hack installed (MCP, etc.) that is causing the problem.
>Try it on a "virgin Workbench".

OK, disabled everything in WBStartup, also disabled KingCON. Same behaviour occurs.
« Last Edit: June 16, 2011, 12:17:36 PM by Minuous »
 

Offline MinuousTopic starter

Re: Ctrl-C handling issues
« Reply #5 on: June 18, 2011, 12:02:15 PM »
Yeah, tried that too, but no good.
  In the whole scheme of things, it's only a minor problem; I will just advise the users not to send any Ctrl-C to the console window.
 

Offline MinuousTopic starter

Re: Ctrl-C handling issues
« Reply #6 on: June 20, 2011, 04:54:02 AM »
OK, I'll check it out. Thanks.