provastub.c

来自「VoiFax is a program that manage voice/da」· C语言 代码 · 共 50 行

C
50
字号
/*  provastub, test program for voice child communication *  Copyright (C) 2004  Simone Freddio & Andrea Emanuelli * *  This program is free software; you can redistribute it and/or modify *  it under the terms of the GNU General Public License as published by *  the Free Software Foundation; either version 2 of the License, or *  (at your option) any later version. * *  This program is distributed in the hope that it will be useful, *  but WITHOUT ANY WARRANTY; without even the implied warranty of *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the *  GNU General Public License for more details. * *  You should have received a copy of the GNU General Public License *  along with this program; if not, write to the Free Software *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA */#include <stdio.h>#include <unistd.h>#include <sys/types.h>int main(int argc, char **argv){	char arg[10];	int pipe_fd[2];	pipe(pipe_fd);	if (fork() == 0)	{		sprintf(arg, "%d", pipe_fd[0]);				printf("Child: executing script with arg = %s\n", arg);		execl("provastub.sh", "provastub.sh", arg, NULL);		return 0;	}	/* send some data to child */	printf("Parent: writing on pipe\n");	write(pipe_fd[1], "Here I go!\n", 11);		printf("Parent: sleeping (ZzZz)\n");	sleep(2);	return 0;}

⌨️ 快捷键说明

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