backlight: Move the fd out of the select range
Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
This commit is contained in:
parent
726f1a38a5
commit
61ec162dc9
|
|
@ -271,7 +271,7 @@ enum backlight_type backlight_exists(const char *iface)
|
|||
|
||||
static int __backlight_init(struct backlight *b, char *iface, int fd)
|
||||
{
|
||||
b->fd = fd_set_cloexec(fd_set_nonblock(fd));
|
||||
b->fd = fd_move_cloexec(fd_set_nonblock(fd));
|
||||
b->iface = iface;
|
||||
return 1;
|
||||
}
|
||||
|
|
|
|||
24
src/fd.c
24
src/fd.c
|
|
@ -31,8 +31,32 @@
|
|||
#include <fcntl.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#include <misc.h> /* MAXCLIENTS */
|
||||
|
||||
#include "fd.h"
|
||||
|
||||
int fd_move_cloexec(int fd)
|
||||
{
|
||||
int newfd;
|
||||
|
||||
newfd = fcntl(fd,
|
||||
#ifdef F_DUPFD_CLOEXEC
|
||||
F_DUPFD_CLOEXEC,
|
||||
#else
|
||||
F_DUPFD,
|
||||
#endif
|
||||
MAXCLIENTS);
|
||||
if (newfd < 0)
|
||||
return fd;
|
||||
|
||||
#ifndef F_DUPFD_CLOEXEC
|
||||
newfd = fd_set_cloexec(newfd);
|
||||
#endif
|
||||
|
||||
close(fd);
|
||||
return newfd;
|
||||
}
|
||||
|
||||
int fd_set_cloexec(int fd)
|
||||
{
|
||||
int flags;
|
||||
|
|
|
|||
Loading…
Reference in New Issue