2 * Copyright (C) 2002 Jeff Dike (jdike@karaya.com)
3 * Licensed under the GPL
6 #include "linux/errno.h"
7 #include "linux/slab.h"
8 #include "linux/signal.h"
9 #include "linux/interrupt.h"
10 #include "asm/semaphore.h"
14 #include "kern_util.h"
19 struct completion ready
;
25 static irqreturn_t
xterm_interrupt(int irq
, void *data
, struct pt_regs
*regs
)
27 struct xterm_wait
*xterm
= data
;
30 fd
= os_rcv_fd(xterm
->fd
, &xterm
->pid
);
35 complete(&xterm
->ready
);
39 int xterm_fd(int socket
, int *pid_out
)
41 struct xterm_wait
*data
;
44 data
= kmalloc(sizeof(*data
), GFP_KERNEL
);
46 printk(KERN_ERR
"xterm_fd : failed to allocate xterm_wait\n");
50 /* This is a locked semaphore... */
51 *data
= ((struct xterm_wait
)
55 init_completion(&data
->ready
);
57 err
= um_request_irq(XTERM_IRQ
, socket
, IRQ_READ
, xterm_interrupt
,
58 SA_INTERRUPT
| SA_SHIRQ
| SA_SAMPLE_RANDOM
,
61 printk(KERN_ERR
"xterm_fd : failed to get IRQ for xterm, "
67 /* ... so here we wait for an xterm interrupt.
69 * XXX Note, if the xterm doesn't work for some reason (eg. DISPLAY
70 * isn't set) this will hang... */
71 wait_for_completion(&data
->ready
);
73 free_irq_by_irq_and_dev(XTERM_IRQ
, data
);
74 free_irq(XTERM_IRQ
, data
);
85 * Overrides for Emacs so that we follow Linus's tabbing style.
86 * Emacs will notice this stuff at the end of the file and automatically
87 * adjust the settings for this buffer only. This must remain at the end
89 * ---------------------------------------------------------------------------
91 * c-file-style: "linux"