Lines Matching +full:blocking +full:- +full:io
22 #include "io/channel-command.h"
23 #include "io/channel-util.h"
24 #include "io/channel-watch.h"
35 * @errp: pointer to a NULL-initialized error object
41 * may be -1 to indicate that stream is not open.
59 ioc->readfd = readfd; in qio_channel_command_new_pid()
60 ioc->writefd = writefd; in qio_channel_command_new_pid()
61 ioc->pid = pid; in qio_channel_command_new_pid()
81 int stdinfd = -1, stdoutfd = -1; in qio_channel_command_new_spawn()
91 error_setg(errp, "%s", err->message); in qio_channel_command_new_spawn()
110 trace_qio_channel_command_abort(ioc, ioc->pid); in qio_channel_command_abort()
111 ret = waitpid(ioc->pid, &status, WNOHANG); in qio_channel_command_abort()
112 trace_qio_channel_command_wait(ioc, ioc->pid, ret, status); in qio_channel_command_abort()
113 if (ret == (pid_t)-1) { in qio_channel_command_abort()
119 (unsigned long long)ioc->pid); in qio_channel_command_abort()
120 return -1; in qio_channel_command_abort()
124 kill(ioc->pid, SIGTERM); in qio_channel_command_abort()
126 kill(ioc->pid, SIGKILL); in qio_channel_command_abort()
130 (unsigned long long)ioc->pid); in qio_channel_command_abort()
131 return -1; in qio_channel_command_abort()
146 TerminateProcess(ioc->pid, 0); in qio_channel_command_abort()
147 ret = WaitForSingleObject(ioc->pid, 1000); in qio_channel_command_abort()
151 (unsigned long long)GetProcessId(ioc->pid)); in qio_channel_command_abort()
152 return -1; in qio_channel_command_abort()
163 ioc->readfd = -1; in qio_channel_command_init()
164 ioc->writefd = -1; in qio_channel_command_init()
165 ioc->pid = 0; in qio_channel_command_init()
171 if (ioc->readfd != -1) { in qio_channel_command_finalize()
172 close(ioc->readfd); in qio_channel_command_finalize()
174 if (ioc->writefd != -1 && in qio_channel_command_finalize()
175 ioc->writefd != ioc->readfd) { in qio_channel_command_finalize()
176 close(ioc->writefd); in qio_channel_command_finalize()
178 ioc->writefd = ioc->readfd = -1; in qio_channel_command_finalize()
179 if (ioc->pid > 0) { in qio_channel_command_finalize()
181 g_spawn_close_pid(ioc->pid); in qio_channel_command_finalize()
214 if (!cioc->blocking && !win32_fd_poll(cioc->readfd, G_IO_IN)) { in qio_channel_command_readv()
220 ret = readv(cioc->readfd, iov, niov); in qio_channel_command_readv()
231 return -1; in qio_channel_command_readv()
249 if (!cioc->blocking && !win32_fd_poll(cioc->writefd, G_IO_OUT)) { in qio_channel_command_writev()
255 ret = writev(cioc->writefd, iov, niov); in qio_channel_command_writev()
265 return -1; in qio_channel_command_writev()
277 cioc->blocking = enabled; in qio_channel_command_set_blocking()
280 if ((cioc->writefd >= 0 && !g_unix_set_fd_nonblocking(cioc->writefd, !enabled, NULL)) || in qio_channel_command_set_blocking()
281 (cioc->readfd >= 0 && !g_unix_set_fd_nonblocking(cioc->readfd, !enabled, NULL))) { in qio_channel_command_set_blocking()
283 return -1; in qio_channel_command_set_blocking()
302 if (cioc->readfd != -1 && in qio_channel_command_close()
303 close(cioc->readfd) < 0) { in qio_channel_command_close()
304 rv = -1; in qio_channel_command_close()
306 if (cioc->writefd != -1 && in qio_channel_command_close()
307 cioc->writefd != cioc->readfd && in qio_channel_command_close()
308 close(cioc->writefd) < 0) { in qio_channel_command_close()
309 rv = -1; in qio_channel_command_close()
311 cioc->writefd = cioc->readfd = -1; in qio_channel_command_close()
315 wp = waitpid(cioc->pid, NULL, 0); in qio_channel_command_close()
316 } while (wp == (pid_t)-1 && errno == EINTR); in qio_channel_command_close()
317 if (wp == (pid_t)-1) { in qio_channel_command_close()
319 (unsigned long long)cioc->pid); in qio_channel_command_close()
320 return -1; in qio_channel_command_close()
323 WaitForSingleObject(cioc->pid, INFINITE); in qio_channel_command_close()
343 qio_channel_util_set_aio_fd_handler(cioc->readfd, read_ctx, io_read, in qio_channel_command_set_aio_fd_handler()
344 cioc->writefd, write_ctx, io_write, in qio_channel_command_set_aio_fd_handler()
354 cioc->readfd, in qio_channel_command_create_watch()
355 cioc->writefd, in qio_channel_command_create_watch()
365 ioc_klass->io_writev = qio_channel_command_writev; in qio_channel_command_class_init()
366 ioc_klass->io_readv = qio_channel_command_readv; in qio_channel_command_class_init()
367 ioc_klass->io_set_blocking = qio_channel_command_set_blocking; in qio_channel_command_class_init()
368 ioc_klass->io_close = qio_channel_command_close; in qio_channel_command_class_init()
369 ioc_klass->io_create_watch = qio_channel_command_create_watch; in qio_channel_command_class_init()
370 ioc_klass->io_set_aio_fd_handler = qio_channel_command_set_aio_fd_handler; in qio_channel_command_class_init()