d0c8dd16f62571618db8118759d7a8ee4e650a76
2 * Copyright (C) 2011 - David Goulet <david.goulet@polymtl.ca>
3 * Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License, version 2 only,
7 * as published by the Free Software Foundation.
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
14 * You should have received a copy of the GNU General Public License along
15 * with this program; if not, write to the Free Software Foundation, Inc.,
16 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
28 #include <common/error.h>
33 * Write to writable pipe used to notify a thread.
35 int notify_thread_pipe(int wpipe
)
39 ret
= write(wpipe
, "!", 1);
41 PERROR("write poll pipe");
48 * Return pointer to home directory path using the env variable HOME.
50 * No home, NULL is returned.
52 const char *get_home_dir(void)
54 return ((const char *) getenv("HOME"));
58 * Create a pipe in dst.
60 int utils_create_pipe(int *dst
)
70 PERROR("create pipe");
77 * Create pipe and set CLOEXEC flag to both fd.
79 * Make sure the pipe opened by this function are closed at some point. Use
82 int utils_create_pipe_cloexec(int *dst
)
90 ret
= utils_create_pipe(dst
);
95 for (i
= 0; i
< 2; i
++) {
96 ret
= fcntl(dst
[i
], F_SETFD
, FD_CLOEXEC
);
98 PERROR("fcntl pipe cloexec");
108 * Close both read and write side of the pipe.
110 void utils_close_pipe(int *src
)
118 for (i
= 0; i
< 2; i
++) {
126 PERROR("close pipe");
This page took 0.035144 seconds and 5 git commands to generate.