amiga.org
     
iconAll times are GMT -6. The time now is 12:44 AM. | Welcome to Forum, please register to access all of our features.

» Amiga.org » Operating System Specific Discussions » Amiga OS » Amiga OS -- Development » while & ctrl+c . 'break' signal.

Amiga OS -- Development This particular forum deals with issues regarding development for all versions of AmigaOS.

Reply
 
Thread Tools Display Modes
Old 11-26-2004, 05:52 AM   #1
kas1e
Technoid
Points: 9,145, Level: 64 Points: 9,145, Level: 64 Points: 9,145, Level: 64
Activity: 27% Activity: 27% Activity: 27%
 
Join Date: Feb 2003
Posts: 414
Default while & ctrl+c . 'break' signal.

hi all. i have little question about ctrl+c and 'break' handling. sas/c compiler used. so:

main()
{
while(1)
{
if (CheckSignal(SIGBREAKF_CTRL_C))
{exit(0);};
}
}


if i press ctrl+c in cli, all ok, and 'status' command said
that not load program. but if i kill my programm by 'break'
command, 'status' said: Proccess 1: No command loaded. but anyway process present. how i must handler 'break' in my whyle loop for good killing by 'break' ?
kas1e is offline   Reply With Quote
Old 11-26-2004, 06:30 AM   #2
Thomas
Kindred of Babble-on
Points: 13,942, Level: 76 Points: 13,942, Level: 76 Points: 13,942, Level: 76
Activity: 13% Activity: 13% Activity: 13%
 
Thomas's Avatar
 
Join Date: Jun 2002
Posts: 2,925
Default Re: while & ctrl+c . 'break' signal.


I hope your real code dosn't busy-wait like the fragment above.

Well, which AmigaOS and which compiler do you use ?

What does your CheckSignal function do ?

Did you free all AmigaOS resources before you exit() ? Exit() only frees ANSI C resources (malloc and similar).

How did you start the program ?

E.g. if you opened two Shell windows, one for your programm and another one for the Break command, after the break your program returns to the Shell, but the Shell window is still there, so the "no command loaded" is correct. The process only disappears if you end the Shell.

To strip down your code fragment to the essential and to make it system-friendly, it should look like this:

#include <proto/exec.h>
#include <dos/dos.h>

int main (void)
{
Wait (SIGBREAKF_CTRL_C);
return (0);
}

Bye,
Thomas
__________________
Email: thomas-rapp@web.de
Home: thomas-rapp.homepage.t-online.de/
Thomas is offline   Reply With Quote
Old 11-26-2004, 11:30 AM   #3
kas1e
Technoid
Points: 9,145, Level: 64 Points: 9,145, Level: 64 Points: 9,145, Level: 64
Activity: 27% Activity: 27% Activity: 27%
 
Join Date: Feb 2003
Posts: 414
Default Re: while & ctrl+c . 'break' signal.

>I hope your real code dosn't busy-wait like the fragment above.

i recv() from socket in while. and test on ctrl+c:
while(recv(.....))
{
.........
ctrl+c();
.........
}

>Well, which AmigaOS and which compiler do you use ?
3.9bb2, sasc/vbcc.

>What does your CheckSignal function do ?
it's not my, it's from dos.library():

NAME
CheckSignal -- Checks for break signals (V36)

FUNCTION
This function checks to see if any signals specified in the mask have been set and if so, returns them. Otherwise it returns FALSE.All signals specified in mask will be cleared.


i don't now, who preferred Wait() or CheckSignal().. btw, thnx for answer, it was 2 open shells so, all is ok.



btw, maybe you know what i can redirect all 'cli' output to
file or memory ? i mean:

char buf[500];

SystemTags("newcli",???); // cli start, but output redirect
// to buf[];

?
kas1e is offline   Reply With Quote
Old 11-26-2004, 11:54 AM   #4
Piru
' union select name,pwd--
Points: 30,457, Level: 100 Points: 30,457, Level: 100 Points: 30,457, Level: 100
Activity: 69% Activity: 69% Activity: 69%
 
Piru's Avatar
 
Join Date: Aug 2002
Location: Helsinki, Finland
Posts: 6,946
Default Re: while & ctrl+c . 'break' signal.

Quote:
i recv() from socket in while. and test on ctrl+c:
while(recv(.....))
bsdsocket.library can do CTRL-C checking for you. See SocketBaseTagList autodoc about SBTC_BREAKMASK.

Quote:
what i can redirect all 'cli' output to
file or memory ? i mean:

char buf[500];

SystemTags("newcli",???); // cli start, but output redirect
// to buf[];
You can't redirect to memory, you need to use temporary file and SYS_Output tag. The output file can use PIPE:, however.
Piru is offline   Reply With Quote
Old 11-26-2004, 02:17 PM   #5
kas1e
Technoid
Points: 9,145, Level: 64 Points: 9,145, Level: 64 Points: 9,145, Level: 64
Activity: 27% Activity: 27% Activity: 27%
 
Join Date: Feb 2003
Posts: 414
Default Re: while & ctrl+c . 'break' signal.

i can create tmp file in memory ? i mean, i not want create file on hdd. (in ram: too, becouse name of file will be anyway). maybe here is some flag for 'memory file' ?

kas1e is offline   Reply With Quote
Old 11-28-2004, 05:05 AM   #6
Thomas
Kindred of Babble-on
Points: 13,942, Level: 76 Points: 13,942, Level: 76 Points: 13,942, Level: 76
Activity: 13% Activity: 13% Activity: 13%
 
Thomas's Avatar
 
Join Date: Jun 2002
Posts: 2,925
Default Re: while & ctrl+c . 'break' signal.


No, you cannot create a file in memory. RAM: or PIPE: are the only possibilities. You can use the task pointer to make the file name unique.

Something like this:

char tempfilename[30];
BPTR tempfile;
sprintf (tempfilename,"t:tempfile%x",FindTask(NULL));
tempfile = Open(tempfilename,MODE_NEWFILE);
Execute ("command",NULL,tempfile);
Close (tempfile);
Open (tempfile,MODE_OLDFILE);
bytes_read = Read (tempfile,buffer,buffersize);
Close (tempfile);
Delete (tempfilename);

Bye,
Thomas
__________________
Email: thomas-rapp@web.de
Home: thomas-rapp.homepage.t-online.de/
Thomas is offline   Reply With Quote
Reply

Bookmarks

Tags
break , ctrl , signal

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Ctrl A-A Diagnostic Screen AndyC Amiga Hardware Issues and discussion 5 02-26-2009 01:46 PM
problem with CTRL+C combo? daniel_swe Amiga Software Issues and Discussion 4 02-13-2009 10:02 AM
Amterm break signal? MrZammler Amiga Software Issues and Discussion 0 05-10-2005 07:29 AM
Christina Applegate REALLY Break A Leg asian1 CH / Entertainment 0 03-13-2005 04:08 PM
Break It Down Again MiAmigo Amiga Software Issues and Discussion 12 12-27-2004 01:31 PM