[gpm]open trick

Deekoo L deekoo@tentacle.net
Sun, 5 Jan 2003 01:43:07 -0800


On Sat, Jan 04, 2003 at 11:48:29PM +0100, Anders Torger wrote:
> 
> When studying the gpm code, I notice that the mouse fd is opened first 
> with O_NDELAY, and then directly after it is reset using fcntl, like 
> this: 
> 
>       if(!strcmp(opt_dev,"-")) fd=0; /* use stdin */
>       else if( (fd=open(opt_dev,O_RDWR | O_NDELAY)) < 0)
>          gpm_report(GPM_PR_OOPS,GPM_MESS_OPEN,opt_dev); 
>              
>       /* and then reset the flag */
>       fcntl(fd,F_SETFL,fcntl(fd,F_GETFL) & ~O_NDELAY);
> 
> 
> I really curious about why this is done.

So GPM doesn't sit there forever if opening the mouse device blocks.
Named pipes without writers will block on open; there are undoubtably
mouse port drivers that do the same.

-- 
"You know, I don't go around peering into other people's pickle jars."-Book
[ Alien sex cults : Deep, probing interrogations ] http://tentacled.net/
[ Mind control codes : Giant yeemp construction ] http://deekoo.net/
[ Realtime communications : Sabre-Toothed Fnords ] deekoo~tentacle.net