[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[linrad] Re: Error exit (and multi-platform)



Leif --

> The thing is that the expected event might never happen
> because the error condition might be within the device driver. 
> (or the mouse/keyboard is not touched.) I need the thread to 
> become killed anyway.

It's almost always possible to ensure this doesn't happen 
asynchronously. See below.

> OK. I understand this to be fine under normal conditions
> but under error conditions some threads might not reach any 
> suitable point - that is why they are CANCEL_ASYNCHRONOUS.
> 
> Normal thread exit is by a return to a join from where the
> thread is created because each thread loop is a 
> {
> while(flag)
>   {
>   code
     pthread_testcancel();  <<<<<
>   }
> return;
> }

Also, it's quite rare that an execution loop in a thread is 
free-running. Usually it is triggered or synchronized by 
something, whether a semphore or a read or a sleep. These 
would be the classical places for deferred cancellation to 
be tested and to take effect.

If it's the case that the code can get wedged, such that it 
can't get to a cancellation point, then there's probably no 
recourse but to take down the entire process anyway.

> I do not want to trap ctrl-C. I would like to send a ctrl-C
> as if the keyboard were pressed. I have noticed that the ctrl-C
> always(?) gives a clean exit.

Sorry, I misunderstood what you were saying.

The reason Ctrl-C works the way it does, is because nothing 
else in a typical process *is* trapping it. Therefore the 
SIGINT propagates to the parent process (the shell) which is 
already trapping SIGINT and associating it with your 
process. The shell is what terminates you in the form of 
your entire process group.

You can get the same effect by sending a signal to yourself:
	kill(0, SIGINT);
This is really all the terminal driver is doing with Ctrl-C 
-- it sees that character come in, and sends a SIGINT to its 
own process group.

> Can I compile a .EXE file for Windows 2000 with GCC under
> Linux? What about Mackintosch?

You can certainly cross-compile, but it would be easier to 
build the Windows EXE using Cygwin. Likewise, Mac OSX *is* 
Unix with a lot of layers on top, very good ones to be sure. 
Any port to a current Mac would be fairly straightforward.

Frank


#############################################################
This message is sent to you because you are subscribed to
  the mailing list <linrad@xxxxxxxxxxxxxxxxxxxxx>.
To unsubscribe, E-mail to: <linrad-off@xxxxxxxxxxxxxxxxxxxxx>
To switch to the DIGEST mode, E-mail to <linrad-digest@xxxxxxxxxxxxxxxxxxxxx>
To switch to the INDEX mode, E-mail to <linrad-index@xxxxxxxxxxxxxxxxxxxxx>
Send administrative queries to  <linrad-request@xxxxxxxxxxxxxxxxxxxxx>
LINRADDARNIL
o