2 * Copyright (C) 2018 - Jérémie Galarneau <jeremie.galarneau@efficios.com>
4 * This program is free software; you can redistribute it and/or modify it
5 * under the terms of the GNU General Public License, version 2 only, as
6 * published by the Free Software Foundation.
8 * This program is distributed in the hope that it will be useful, but WITHOUT
9 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
10 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
13 * You should have received a copy of the GNU General Public License along with
14 * this program; if not, write to the Free Software Foundation, Inc., 51
15 * Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
21 #include <common/fd-tracker/utils.h>
22 #include <common/utils.h>
25 int open_pipe_cloexec(void *data
, int *fds
)
29 ret
= utils_create_pipe_cloexec(fds
);
38 int close_pipe(void *data
, int *pipe
)
40 utils_close_pipe(pipe
);
41 pipe
[0] = pipe
[1] = -1;
45 int fd_tracker_util_close_fd(void *unused
, int *fd
)
50 int fd_tracker_util_pipe_open_cloexec(struct fd_tracker
*tracker
,
51 const char *name
, int *pipe
)
54 const char *name_prefix
;
57 name_prefix
= name
? name
: "Unknown pipe";
58 ret
= asprintf(&names
[0], "%s (read end)", name_prefix
);
62 ret
= asprintf(&names
[1], "%s (write end)", name_prefix
);
67 ret
= fd_tracker_open_unsuspendable_fd(tracker
, pipe
,
68 (const char **) names
, 2, open_pipe_cloexec
, NULL
);
75 int fd_tracker_util_pipe_close(struct fd_tracker
*tracker
, int *pipe
)
77 return fd_tracker_close_unsuspendable_fd(tracker
,
78 pipe
, 2, close_pipe
, NULL
);
This page took 0.032152 seconds and 5 git commands to generate.