Ah, you will have to be careful here. The
opengroup.org signature for execlp is the following:
int execlp(const char *[I]file, const char *[I]arg0, ... /*, (char *)0 */);[/I][/I]
This hints that the parameter list is both variable and should end in a null pointer (NULL can be useful.)
Quote
"Ye application shall ensure that the last member of this array is a null pointer"
The following should correct this issue:
execlp( "cat", "cat", argv[1], NULL);
I do not believe that the program runs twice, it may be that the garbage is read as a file (i.e. cat file1.txt file2.txt) where file2.txt is in this case garbage ASCII due to lack of termination.
Alexander.
Be sure to read the updated
FAQ! || Health is achieved through the same 10,000 steps.
If a suggested code/method fails, informing us is less important than telling us
why or
what errors occurred.