X-Git-Url: https://gapil.gnulinux.it/gitweb/?a=blobdiff_plain;f=sources%2FForkTest.c;h=d57ef7a7436c469f0620ce45c3dfee50d9d31fe1;hb=2df3e366683f4df738d40a05b97f820fde1648d9;hp=da38629b41892b6be703821222303d4da4073576;hpb=0d1802dcd969187e6133ba143ebc473c9fefc259;p=gapil.git diff --git a/sources/ForkTest.c b/sources/ForkTest.c index da38629..d57ef7a 100644 --- a/sources/ForkTest.c +++ b/sources/ForkTest.c @@ -1,3 +1,21 @@ +/* ForkTest.c + * + * Copyright (C) 2001 Simone Piccardi + * + * 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., 675 Mass Ave, Cambridge, MA 02139, USA. + */ /**************************************************************** * * Program ForkTest.c: @@ -8,7 +26,7 @@ * * Usage: forktest -h give all info's * - * $Id: ForkTest.c,v 1.1 2001/09/09 17:39:15 piccardi Exp $ + * $Id: ForkTest.c,v 1.4 2001/09/14 22:16:41 piccardi Exp $ * ****************************************************************/ /* @@ -28,23 +46,30 @@ int main(int argc, char *argv[]) /* * Variables definition */ - int i; - int nchild; + int nchild, i; pid_t pid; + int wait_child=0; + int wait_parent=0; /* * Input section: decode command line parameters * Use getopt function */ opterr = 0; /* don't want writing to stderr */ - while ( (i = getopt(argc, argv, "h")) != -1) { + while ( (i = getopt(argc, argv, "hp:c:")) != -1) { switch (i) { /* * Handling options */ - case 'h': + case 'h': /* help option */ printf("Wrong -h option use\n"); usage(); - return(0); + return -1; + break; + case 'c': /* take wait time for childen */ + wait_child=strtol(optarg, NULL, 10); /* convert input */ + break; + case 'p': /* take wait time for childen */ + wait_parent=strtol(optarg, NULL, 10); /* convert input */ break; case '?': /* unrecognized options */ printf("Unrecognized options -%c\n",optopt); @@ -68,16 +93,20 @@ int main(int argc, char *argv[]) printf("Test for forking %d child\n", nchild); /* loop to fork children */ for (i=0; i