mystop.c.svn-base

来自「os project / shell 程序」· SVN-BASE 代码 · 共 37 行

SVN-BASE
37
字号
/*  * mystop.c - Another handy routine for testing your tiny shell *  * usage: mystop <n> * Sleeps for <n> seconds and sends SIGTSTP to itself. * */#include <stdio.h>#include <unistd.h>#include <stdlib.h>#include <sys/types.h>#include <sys/wait.h>#include <signal.h>int main(int argc, char **argv) {    int i, secs;    pid_t pid;     if (argc != 2) {	fprintf(stderr, "Usage: %s <n>\n", argv[0]);	exit(0);    }    secs = atoi(argv[1]);    for (i=0; i < secs; i++)       sleep(1);	    pid = getpid();     if (kill(-pid, SIGTSTP) < 0)       fprintf(stderr, "kill (tstp) error");    exit(0);}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?