Welcome, Guest. Please login or register.

Author Topic: while & ctrl+c . 'break' signal.  (Read 2773 times)

Description:

0 Members and 1 Guest are viewing this topic.

Offline Thomas

Re: while & ctrl+c . 'break' signal.
« on: November 26, 2004, 01:30:34 PM »

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

Offline Thomas

Re: while & ctrl+c . 'break' signal.
« Reply #1 on: November 28, 2004, 12:05:26 PM »

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