Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
M
mpd
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Иван Мажукин
mpd
Commits
1573ea14
Commit
1573ea14
authored
Nov 07, 2009
by
Max Kellermann
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
inotify: set close-on-exec flag
Added wrapper for inotify_init1() to fd_util.c.
parent
e3af0032
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
31 additions
and
1 deletion
+31
-1
fd_util.c
src/fd_util.c
+26
-0
fd_util.h
src/fd_util.h
+3
-0
inotify_source.c
src/inotify_source.c
+2
-1
No files found.
src/fd_util.c
View file @
1573ea14
...
...
@@ -35,6 +35,10 @@
#include <sys/socket.h>
#endif
#ifdef HAVE_INOTIFY_INIT
#include <sys/inotify.h>
#endif
#ifndef WIN32
static
int
...
...
@@ -169,3 +173,25 @@ accept_cloexec(int fd, struct sockaddr *address, size_t *address_length_r)
return
ret
;
}
#ifdef HAVE_INOTIFY_INIT
int
inotify_init_cloexec
(
void
)
{
int
fd
;
#ifdef HAVE_INOTIFY_INIT1
fd
=
inotify_init1
(
IN_CLOEXEC
);
if
(
fd
>=
0
||
errno
!=
ENOSYS
)
return
fd
;
#endif
fd
=
inotify_init
();
if
(
fd
>=
0
)
fd_set_cloexec
(
fd
,
true
);
return
fd
;
}
#endif
src/fd_util.h
View file @
1573ea14
...
...
@@ -50,4 +50,7 @@ socket_cloexec(int domain, int type, int protocol);
int
accept_cloexec
(
int
fd
,
struct
sockaddr
*
address
,
size_t
*
address_length_r
);
int
inotify_init_cloexec
(
void
);
#endif
src/inotify_source.c
View file @
1573ea14
...
...
@@ -19,6 +19,7 @@
#include "inotify_source.h"
#include "fifo_buffer.h"
#include "fd_util.h"
#include <sys/inotify.h>
#include <unistd.h>
...
...
@@ -105,7 +106,7 @@ mpd_inotify_source_new(mpd_inotify_callback_t callback, void *callback_ctx,
struct
mpd_inotify_source
*
source
=
g_new
(
struct
mpd_inotify_source
,
1
);
source
->
fd
=
inotify_init
();
source
->
fd
=
inotify_init
_cloexec
();
if
(
source
->
fd
<
0
)
{
g_set_error
(
error_r
,
mpd_inotify_quark
(),
errno
,
"inotify_init() has failed: %s"
,
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment