Reply to post: Re: Software has to pay attention

Meltdown/Spectre week three: World still knee-deep in something nasty

KSM-AZ

Re: Software has to pay attention

Not easy per se, not generally difficult.

You have to either set the iostream to NONBLOCK or use a select call. The issue in a pipe/ipc is the stream you are reading from and how buggy your select() function is.

Select can be a real bitch, you have to load your file descriptors you want to monitor in arrays for read write, give it a count with a timeout 0. I wrote a simplified C function long ago along the lines of has_data(int fd) ... nested in a readline function. If you can get NONBLOCK on your stream you can just do a read(int fd, char *buf...) and it will return 0 if you got nuthin. Much fun with ioctl's on serial lines and other character devices.

YMMV

POST COMMENT House rules

Not a member of The Register? Create a new account here.

  • Enter your comment

  • Add an icon

Anonymous cowards cannot choose their icon

SUBSCRIBE TO OUR WEEKLY TECH NEWSLETTER

Biting the hand that feeds IT © 1998–2019