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.
18 #include <common/fd-tracker/utils.h>
19 #include <common/utils.h>
24 static int open_pipe_cloexec(void *data
, int *fds
)
26 return utils_create_pipe_cloexec(fds
);
29 static int close_pipe(void *data
, int *pipe
)
31 utils_close_pipe(pipe
);
32 pipe
[0] = pipe
[1] = -1;
36 int fd_tracker_util_close_fd(void *unused
, int *fd
)
41 int fd_tracker_util_pipe_open_cloexec(
42 struct fd_tracker
*tracker
, const char *name
, int *pipe
)
45 const char *name_prefix
;
48 name_prefix
= name
? name
: "Unknown pipe";
49 ret
= asprintf(&names
[0], "%s (read end)", name_prefix
);
53 ret
= asprintf(&names
[1], "%s (write end)", name_prefix
);
58 ret
= fd_tracker_open_unsuspendable_fd(tracker
, pipe
,
59 (const char **) names
, 2, open_pipe_cloexec
, NULL
);
66 int fd_tracker_util_pipe_close(struct fd_tracker
*tracker
, int *pipe
)
68 return fd_tracker_close_unsuspendable_fd(
69 tracker
, pipe
, 2, close_pipe
, NULL
);
This page took 0.030827 seconds and 5 git commands to generate.