mirror of
https://github.com/X11Libre/xf86-video-intel.git
synced 2026-03-24 01:24:12 +00:00
drop fd_move_cloexec()
There's really no need to duplicate fd to a trivial sysfs file, neither any need to explicitly mark it as close-on-exec. There's no locking whatsoever involved, even parallel writes are fully supported for sysfs attribute files. And the way it was done was really weird and fragile: it just brutely overwrote fd # MAXCLIENTS. The MAXCLIENTS define is internal to the Xserver, outside of individual driver's concern, and drivers really shouldn't directly mess with the fd table that way - they have no way to make sure it's really done right. Therefore, just drop this all and leave the fd as it is. Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
This commit is contained in:
committed by
Enrico Weigelt
parent
5e1e6554ed
commit
4ef542eb13
@@ -326,7 +326,7 @@ int backlight_exists(const char *iface)
|
||||
|
||||
static int __backlight_init(struct backlight *b, char *iface, int fd)
|
||||
{
|
||||
b->fd = fd_move_cloexec(fd_set_nonblock(fd));
|
||||
b->fd = fd_set_nonblock(fd);
|
||||
b->iface = iface;
|
||||
return 1;
|
||||
}
|
||||
|
||||
22
src/fd.c
22
src/fd.c
@@ -37,28 +37,6 @@
|
||||
|
||||
#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;
|
||||
|
||||
Reference in New Issue
Block a user