2 * Copyright (C) 2001 - 2007 Jeff Dike (jdike@{addtoit,linux.intel}.com)
3 * Licensed under the GPL
6 #include <linux/slab.h>
7 #include <linux/completion.h>
8 #include <linux/irqreturn.h>
14 struct completion ready;
20 static irqreturn_t xterm_interrupt(int irq, void *data)
22 struct xterm_wait *xterm = data;
25 fd = os_rcv_fd(xterm->fd, &xterm->pid);
30 complete(&xterm->ready);
35 int xterm_fd(int socket, int *pid_out)
37 struct xterm_wait *data;
40 data = kmalloc(sizeof(*data), GFP_KERNEL);
42 printk(KERN_ERR "xterm_fd : failed to allocate xterm_wait\n");
46 /* This is a locked semaphore... */
47 *data = ((struct xterm_wait) { .fd = socket,
50 init_completion(&data->ready);
52 err = um_request_irq(XTERM_IRQ, socket, IRQ_READ, xterm_interrupt,
53 IRQF_DISABLED | IRQF_SHARED | IRQF_SAMPLE_RANDOM,
56 printk(KERN_ERR "xterm_fd : failed to get IRQ for xterm, "
62 /* ... so here we wait for an xterm interrupt.
64 * XXX Note, if the xterm doesn't work for some reason (eg. DISPLAY
65 * isn't set) this will hang... */
66 wait_for_completion(&data->ready);
68 free_irq(XTERM_IRQ, data);