From: McLoughlin, Mark (mark.mcloughlin at domain intel.com)
Date: Mon 24 Jul 2000 - 14:23:33 IST
> The first is I would like use the function rand and I can't find out
> (sorry, I am net very clever you know...) how I can initialize the series
> of random number with the clock or something like that. I get each time
> the
> same serie.
>
Look up the man page for rand and the srand function is with it.
You could seed the randomizer with the current time in seconds to
get a unique value each time.
Have a look at the time function.
Somit like srand( time() ) should work. (Dunno I never use rand )
> My second problem is I would like run another program. So, I use :
> pid=fork();
> if (pid==1) { //maybe it's zero, I can't remember
> execv(myprogram,argv);
> exit(0);
> }
>
> The problem is when I am doing a ps to see the list of the processus, the
> program each time I run it is in the list like a zombie. How it is
> possible
> to finish it completely ?
>
Have a look at waitpid to make sure that your parent process doesn't
finish before your child.
Someit like waitpid( kidpid , NULL , 0 );
Once again, man is your friend
Good Luck,
Mark
> --
> Irish Linux Users' Group: ilug at domain linux.ie
> http://www.linux.ie/mailman/listinfo/ilug for (un)subscription
> information.
> List maintainer: listmaster at domain linux.ie
This archive was generated by hypermail 2.1.6 : Thu 06 Feb 2003 - 13:06:58 GMT