migration/multifd: correct multifd_send_thread to trace the flags
[qemu/armbru.git] / qga / cutils.c
blobb21bcf3683089c2ec4170edb5eb3fccb59276ec1
1 /*
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.
4 */
6 #include "qemu/osdep.h"
7 #include "cutils.h"
8 #include "qapi/error.h"
10 /**
11 * qga_open_cloexec:
12 * @name: the pathname to open
13 * @flags: as in open()
14 * @mode: 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)
22 int ret;
24 #ifdef O_CLOEXEC
25 ret = open(name, flags | O_CLOEXEC, mode);
26 #else
27 ret = open(name, flags, mode);
28 if (ret >= 0) {
29 qemu_set_cloexec(ret);
31 #endif
33 return ret;