2 * This work is licensed under the terms of the GNU GPL, version 2 or later.
3 * See the COPYING file in the top-level directory.
6 #include "qemu/osdep.h"
8 #include "qapi/error.h"
12 * @name: the pathname to open
13 * @flags: as in open()
16 * A wrapper for open() function which sets O_CLOEXEC.
18 * On error, -1 is returned.
20 int qga_open_cloexec(const char *name, int flags, mode_t mode)
25 ret = open(name, flags | O_CLOEXEC, mode);
27 ret = open(name, flags, mode);
29 qemu_set_cloexec(ret);