On Sat, Jun 16, 2007 at 07:18:17PM +0200, Michael Hanselmann wrote:
>   if (stat("/sys/module/usbhid/parameters/pb_fnmode", &st) == 0) {
>   […]

>   fd = open(path, O_RDONLY);

I just noticed the race condition there. A better way:

fd = open("/sys/module/usbhid/parameters/pb_fnmode", O_RDWR);
if (fd < 0) {
    fd = open("/sys/module/hid/parameters/pb_fnmode", O_RDWR);
    if (fd < 0) {
        /* Not available */
    }
}
/* Use fd */

Greets,
Michael

-- 
http://hansmi.ch/


-- 
To UNSUBSCRIBE, email to [EMAIL PROTECTED]
with a subject of "unsubscribe". Trouble? Contact [EMAIL PROTECTED]

Reply via email to