Welcome, Guest. Please login or register.

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

Description:

0 Members and 1 Guest 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 lsmart

  • Sr. Member
  • ****
  • Join Date: Jun 2009
  • Posts: 433
    • Show only replies by lsmart
Re: Ctrl-C handling issues
« Reply #1 on: June 11, 2011, 04:28:55 PM »
I am sure I canĀ“t help you, but maybe you find the souliton if you ask yourself some smart questions like:
* Does your program have multiple tasks?
* Is it started from Workbench, or is the break signal sent via CLI?

Seeing the string look identical is nice, but have you patched your code or used a debugger to ensure it is really read from that memory location?
 

Offline lsmart

  • Sr. Member
  • ****
  • Join Date: Jun 2009
  • Posts: 433
    • Show only replies by lsmart
Re: Ctrl-C handling issues
« Reply #2 on: June 11, 2011, 04:37:28 PM »
One more:

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

Offline MinuousTopic starter

Re: Ctrl-C handling issues
« Reply #3 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 #4 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 mongo

  • Hero Member
  • *****
  • Join Date: Feb 2002
  • Posts: 964
    • Show only replies by mongo
Re: Ctrl-C handling issues
« Reply #5 on: June 11, 2011, 05:52:54 PM »
Try:

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

Offline x303

Re: Ctrl-C handling issues
« Reply #6 on: June 11, 2011, 08:07:59 PM »
The solution from Mongo should do the trick. Look here: http://cataclysm.cx/random/amiga/reference/Libraries_Manual_guide/node0019.html
 

Offline MinuousTopic starter

Re: Ctrl-C handling issues
« Reply #7 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 x303

Re: Ctrl-C handling issues
« Reply #8 on: June 13, 2011, 01:15:50 AM »
Hmmm, checked some old code. All voids, no ints. Works over here.

#ifdef SAS_C
int CXBRK(void) { return(0); }
void __regargs __chkabort(void);
void __regargs __chkabort(void) {}
#endif

Edit:
Btw I thought you developed AA with Stormc (looking at the code). Why bother 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.
« Last Edit: June 13, 2011, 01:28:12 AM by x303 »
 

Offline ChaosLord

  • Hero Member
  • *****
  • Join Date: Nov 2003
  • Posts: 2608
    • Show only replies by ChaosLord
    • http://totalchaoseng.dbv.pl/news.php
Re: Ctrl-C handling issues
« Reply #9 on: June 13, 2011, 02:08:01 AM »
I would happily check my code to see how I do it but my Amiga HD is knackered :(
Wanna try a wonderfull strategy game with lots of handdrawn anims,
Magic Spells and Monsters, Incredible playability and lastability,
English speech, etc. Total Chaos AGA
 

Offline ChaosLord

  • Hero Member
  • *****
  • Join Date: Nov 2003
  • Posts: 2608
    • Show only replies by ChaosLord
    • http://totalchaoseng.dbv.pl/news.php
Re: Ctrl-C handling issues
« Reply #10 on: June 13, 2011, 02:10:33 AM »
Quote from: x303;644556
Btw I thought you developed AA with Stormc (looking at the code). Why bother with sas/c ???
Because he is intelligent enough to know that SASC Rules Them All :)
Wanna try a wonderfull strategy game with lots of handdrawn anims,
Magic Spells and Monsters, Incredible playability and lastability,
English speech, etc. Total Chaos AGA
 

Offline ChaosLord

  • Hero Member
  • *****
  • Join Date: Nov 2003
  • Posts: 2608
    • Show only replies by ChaosLord
    • http://totalchaoseng.dbv.pl/news.php
Re: Ctrl-C handling issues
« Reply #11 on: June 13, 2011, 02:16:07 AM »
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.
Wanna try a wonderfull strategy game with lots of handdrawn anims,
Magic Spells and Monsters, Incredible playability and lastability,
English speech, etc. Total Chaos AGA
 

Offline x303

Re: Ctrl-C handling issues
« Reply #12 on: June 13, 2011, 02:38:01 AM »
If you wanna check out the _cxbrk routine, it's hidden in sc:source :idea:
 

Offline lsmart

  • Sr. Member
  • ****
  • Join Date: Jun 2009
  • Posts: 433
    • Show only replies by lsmart
Re: Ctrl-C handling issues
« Reply #13 on: June 13, 2011, 07:42:30 AM »
Quote from: Minuous;644249
>it auto-opens the CLI window on its first printf().

You are using printf? Doesn't this mean you are including and linking some standard C-Library stuff, which might include its own definitions for handling BRK? Are you using your own startup code?

Maybe ChaosLord is right. Try it on a "virgin Workbench". How often does the problem occur? You could write a small program/loop that does nothing but start AA (or better a third small programm that just shows the CTRL-C problem) and then send BRK .
 

Offline MinuousTopic starter

Re: Ctrl-C handling issues
« Reply #14 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 »