# drivers/tty/vt/vt_ioctl.c
/**
* vt_waitactive - active console wait
* @event: event code
* @n: new console
*
* Helper for event waits. Used to implement the legacy
* event waiting ioctls in terms of events
*/
int vt_waitactive(int n)
{
struct vt_event_wait vw;
do {
vw.event.event = VT_EVENT_SWITCH;
__vt_event_queue(&vw);
if (n == fg_console + 1) {
__vt_event_dequeue(&vw);
break;
}
__vt_event_wait(&vw);
__vt_event_dequeue(&vw);
if (vw.done == 0)
return -EINTR;
} while (vw.event.newev != n);
return 0;
}
# drivers/tty/vt/vt_ioctl.c
static void __vt_event_wait(struct vt_event_wait *vw)
{
/* Wait for it to pass */
wait_event_interruptible(vt_event_waitqueue, vw->done);
}
# include/linux/wait.h
/**
* wait_event_interruptible - sleep until a condition gets true
* @wq_head: the waitqueue to wait on
* @condition: a C expression for the event to wait for
*
* The process is put to sleep (TASK_INTERRUPTIBLE) until the
* @condition evaluates to true or a signal is received.
* The @condition is checked each time the waitqueue @wq_head is woken up.
*
* wake_up() has to be called after changing any variable that could
* change the result of the wait condition.
*
* The function will return -ERESTARTSYS if it was interrupted by a
* signal and 0 if @condition evaluated to true.
$ cat /proc/5222/stack wait.isra. 3.part. 4+0x40/ 0x90 0x80/0xd0 0xd34/0x1150 0xf6/0x8c0 ioctl+0xa8/ 0x630 0x75/0x80 ioctl+0x1a/ 0x20 64+0x5a/ 0x120 64_after_ hwframe+ 0x44/0xa9
[<0>] __vt_event_
[<0>] vt_waitactive+
[<0>] vt_ioctl+
[<0>] tty_ioctl+
[<0>] do_vfs_
[<0>] ksys_ioctl+
[<0>] __x64_sys_
[<0>] do_syscall_
[<0>] entry_SYSCALL_
[<0>] 0xffffffffffffffff
# drivers/ tty/vt/ vt_ioctl. c
/**
* vt_waitactive - active console wait
* @event: event code
* @n: new console
*
* Helper for event waits. Used to implement the legacy
* event waiting ioctls in terms of events
*/
int vt_waitactive(int n) queue(& vw); dequeue( &vw); wait(&vw) ; dequeue( &vw);
{
struct vt_event_wait vw;
do {
vw.event.event = VT_EVENT_SWITCH;
__vt_event_
if (n == fg_console + 1) {
__vt_event_
break;
}
__vt_event_
__vt_event_
if (vw.done == 0)
return -EINTR;
} while (vw.event.newev != n);
return 0;
}
# drivers/ tty/vt/ vt_ioctl. c wait(struct vt_event_wait *vw) interruptible( vt_event_ waitqueue, vw->done);
static void __vt_event_
{
/* Wait for it to pass */
wait_event_
}
# include/ linux/wait. h interruptible - sleep until a condition gets true IBLE) until the
/**
* wait_event_
* @wq_head: the waitqueue to wait on
* @condition: a C expression for the event to wait for
*
* The process is put to sleep (TASK_INTERRUPT
* @condition evaluates to true or a signal is received.
* The @condition is checked each time the waitqueue @wq_head is woken up.
*
* wake_up() has to be called after changing any variable that could
* change the result of the wait condition.
*
* The function will return -ERESTARTSYS if it was interrupted by a
* signal and 0 if @condition evaluated to true.