很明显伪终端到终端用户之间做了很多工作
上图可能由下面的命令形成:
setsid创建新会话,如果不是进程组组长,则创建新会话
[manjingliu@localhost part_9]$ ./ttin &
[1] 21667
[manjingliu@localhost part_9]$ xxxxxxxxxxxxxxxxxxxxxxxxx
[manjingliu@localhost part_9]$ xxxxxfgxxxxx %1xxxxx
./ttin
^C
# 这里关闭后台作业进程进行io输入输出
[manjingliu@localhost part_9]$ stty tostop
[manjingliu@localhost part_9]$ ./ttin &
[1] 21669
[manjingliu@localhost part_9]$
[1]+ Stopped ./ttin
[manjingliu@localhost part_9]$ fg %1
./ttin
xxxxxxxxxxxxxxx^C
[manjingliu@localhost part_9]$ strace ./ttin &
[1] 21672
[manjingliu@localhost part_9]$ execve("./ttin", ["./ttin"], [/* 22 vars */]) = 0
brk(NULL) = 0x211a000
mmap(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7f5f1920e000
access("/etc/ld.so.preload", R_OK) = -1 ENOENT (No such file or directory)
open("/etc/ld.so.cache", O_RDONLY|O_CLOEXEC) = 3
fstat(3, {st_mode=S_IFREG|0644, st_size=34465, ...}) = 0
mmap(NULL, 34465, PROT_READ, MAP_PRIVATE, 3, 0) = 0x7f5f19205000
close(3) = 0
open("/lib64/libc.so.6", O_RDONLY|O_CLOEXEC) = 3
read(3, "\177ELF\2\1\1\3\0\0\0\0\0\0\0\0\3\0>\0\1\0\0\0P%\2\0\0\0\0\0"..., 832) = 832
fstat(3, {st_mode=S_IFREG|0755, st_size=2173512, ...}) = 0
mmap(NULL, 3981792, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_DENYWRITE, 3, 0) = 0x7f5f18c21000
mprotect(0x7f5f18de4000, 2093056, PROT_NONE) = 0
mmap(0x7f5f18fe3000, 24576, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0x1c2000) = 0x7f5f18fe3000
mmap(0x7f5f18fe9000, 16864, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_ANONYMOUS, -1, 0) = 0x7f5f18fe9000
close(3) = 0
mmap(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7f5f19204000
mmap(NULL, 8192, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7f5f19202000
arch_prctl(ARCH_SET_FS, 0x7f5f19202740) = 0
mprotect(0x7f5f18fe3000, 16384, PROT_READ) = 0
mprotect(0x600000, 4096, PROT_READ) = 0
mprotect(0x7f5f1920f000, 4096, PROT_READ) = 0
munmap(0x7f5f19205000, 34465) = 0
write(1, "xxxxx", 5) = ? ERESTARTSYS (To be restarted if SA_RESTART is set)
--- SIGTTOU {si_signo=SIGTTOU, si_code=SI_KERNEL} ---
--- stopped by SIGTTOU ---