Login
Username:

Password:

Remember me



Lost Password?

Register now!

Sections

Who's Online
161 user(s) are online (149 user(s) are browsing Forums)

Members: 0
Guests: 161

more...

Support us!

Headlines

 
  Register To Post  

newlib's waitselect() and Ctrl-C
Amigans Defender
Amigans Defender


See User information
I was expecting newlib's waitselect() to work like the WaitSelect() in bsdsocket.library, but the Ctrl-C handling seems to be broken.

If I send a Ctrl-C to a task waiting in waitselect() using netshutdown, the task just goes **BREAK and everything freezes because Intuition or something gets upset.

WaitSelect(), in contrast, returns -1 on a Ctrl-C so it can be caught by the application.

Usually I'll Wait() on a SIGBREAKF_CTRLC, but adding that to the signal mask in waitselect() just causes a spurious Ctrl-C to be received.

Any suggestions how to work around this? Or does it need fixing in newlib?

Go to top
Re: newlib's waitselect() and Ctrl-C
Home away from home
Home away from home


See User information
It's likely not breaking at the waitselect() but at any io functions that does a chkabort() (or equiv ) so you need to install a signal handler for SIG_BREAK.






Go to top
Re: newlib's waitselect() and Ctrl-C
Just can't stay away
Just can't stay away


See User information
@Chris

If you want to do your own CTRL-C handling you have to either disable the clib's CTRL-C signal handling or avoid all clib function calls.

You can disable newlib break signal handling by:
signal(SIGINT, SIG_IGN);
signal(SIGTERM, SIG_IGN);

The above code is from SRec. Only one of them corresponds to CTRL-C (maybe SIGINT?) but disabling both of them just to be safe doesn't hurt either.

Go to top
Re: newlib's waitselect() and Ctrl-C
Amigans Defender
Amigans Defender


See User information
@salass00

It's SIGINT apparently.

I thought I was already doing this, but I'm not, so that's likely the problem.

Go to top
Re: newlib's waitselect() and Ctrl-C
Amigans Defender
Amigans Defender


See User information
@salass00

That stopped it terminating in waitselect, but waitselect is still not returning -1 when it receives a Ctrl-C, and adding a SIGBREAKF_CTRLC to the signal mask is still sporadically causing that bit to be returned set.

So it's an improvement but still not quite right.

Go to top
Re: newlib's waitselect() and Ctrl-C
Home away from home
Home away from home


See User information
WaitSelect() doesn't return -1 on CTR-C but on the standard break sigbnal set by SBTC_BREAKMASK (which by default is CTRL-C) perhaps since CTRL_C is handled by the c library bsdsocket library is open with this disabled? (it's also an error case of course you need to test for EINTR but you probably know that).

The spurious returning with SIG_BREAKF_CTRLC set sounds odd though. There no other process that could be sending this to your process?




Go to top
Re: newlib's waitselect() and Ctrl-C
Amigans Defender
Amigans Defender


See User information
@broadblues

Quote:
The spurious returning with SIG_BREAKF_CTRLC set sounds odd though. There no other process that could be sending this to your process?


No; if I use Wait() it doesn't happen.

Go to top

  Register To Post

 




Currently Active Users Viewing This Thread: 1 ( 0 members and 1 Anonymous Users )




Powered by XOOPS 2.0 © 2001-2024 The XOOPS Project