ALT+CTRL+F2 - Switch Terminal - agetty process

From: Mohit Gupta
Date: Thu Aug 09 2018 - 01:04:56 EST


I am trying to understand how agetty process is called when
ALT+CTRL+F2/ALT+CTRL+F3/.... keys are pressed in CentOS or in any
other linux distro.

What I know so far
- systemd runs agetty.service with next tty[N] number
- agetty then run login process and then other process continues.


What I want to know
---------------------------
When ALT+CTRL+F2 keys are pressed what happens in kernel?

Looking at keyboard.c seems k_cons is called which calls set_console.

static void k_cons(struct vc_data *vc, unsigned char value, char up_flag)
{
if (up_flag)
return;

set_console(value);
}

I am not sure how set_console triggers agetty with tty2/tty3/tty4 as
one of it's parameter.

Any information will be helpful.

Regards
Mohit