|
发表于 2022-5-23 10:41:08
|
显示全部楼层
- $ ls
- pause.c
- $ cat pause.c
- #include <stdio.h>
- #include <sys/ioctl.h>
- #include <unistd.h>
- #include <termios.h>
- int main(void) {
- {
- struct termios termios;
- ioctl(STDIN_FILENO, TCGETS, &termios);
- termios.c_lflag &= ~(ICANON | ECHO);
- ioctl(STDIN_FILENO, TCSETS, &termios);
- }
- printf("Press any key to continue...");
- getchar();
- {
- struct termios termios;
- ioctl(STDIN_FILENO, TCGETS, &termios);
- termios.c_lflag |= ICANON | ECHO;
- ioctl(STDIN_FILENO, TCSETS, &termios);
- }
- putchar('\n');
- return 0;
- }
- $ gcc -Wall -O3 -o pause pause.c $(pkg-config --cflags --libs ncurses)
- $ ls
- pause pause.c
- $ ./pause
- Press any key to continue...
- $ ./pause
- Press any key to continue...
- $ ./pause
- Press any key to continue...
- $ ./pause
- Press any key to continue...
- $ cp pause ~/bin
- $ cd ~/tmp
- $ cat main.py
- #!/usr/bin/env python
- #coding=utf-8
- import os
- print('hello world!')
- os.system('pause')
- print('hello world!')
- $ ./main.py
- hello world!
- Press any key to continue...
- hello world!
- $ ./main.py
- hello world!
- Press any key to continue...
- hello world!
- $ ./main.py
- hello world!
- Press any key to continue...
- hello world!
- $
- $
- $
- $ ./main.py
- hello world!
- Press any key to continue...
- hello world!
- $
复制代码
|
|