1 // SPDX-License-Identifier: GPL-2.0
3 * Copyright (C) 2001 - 2007 Jeff Dike (jdike@{addtoit,linux.intel}.com)
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_SHARED
, "xterm", data
);
55 printk(KERN_ERR
"xterm_fd : failed to get IRQ for xterm, "
61 /* ... so here we wait for an xterm interrupt.
63 * XXX Note, if the xterm doesn't work for some reason (eg. DISPLAY
64 * isn't set) this will hang... */
65 wait_for_completion(&data
->ready
);
67 um_free_irq(XTERM_IRQ
, data
);