....
If you see anything that is a bad habit please tell me. I am not as familiar with C as I am with Java.
function declarations of wait, atoi, getpid. linker will find the functions anyway, but gcc won't be able to tell you if you're using it wrong. By which I mean if you did:
atoi(22, "xxxxx", 3.14);
the program would compile without even a warning and you'd get a segfault when atoi tries to access address 0x16(22). Although once declared(#include <stdlib.h>) you'll get a warning:
atoi.c: In function ‘main’:
atoi.c:x: warning: passing argument 1 of ‘atoi’ makes pointer from integer without a cast
/usr/include/stdlib.h:148: note: expected ‘const char *’ but argument is of type ‘int’
To avoid such things use the -Wall(Warning all) switch on gcc, it'll tell you . Important option if you're beginning in C. If you ever have trouble locating a function or macro, try man'ing it, if fail grep is alot of help:
$ grep -r "extern.*atoi *(" /usr/include
/usr/include/pgsql/server/utils/builtins.h:extern int32 pg_atoi(char *s, int size, int c);
/usr/include/stdlib.h:extern int atoi (__const char *__nptr)
quick note about naming conventions:
-> thisIsRare, ExceptSometimesLikeThis(mostly winAPI), cstyle, c_style
of course like any language, doesn't matter.
also i've never seen it called argvMain before, I feel the exec argument should be the one renamed. although you're free to call it what you want.
Apart from this I don't see any problems, maybe move sprintf + argv out of fork loop.
edit:
char *argv[10] is an array of length 10 holding (char*), setting it to 10(im assuming to fit arg1, arg2) isn't neccessary. Not copying data, only setting pointers. You only need *argv[4], try this:
char *argv[10], argv2[4][10];
printf("%d %d\n", sizeof(argv[0]), sizeof(argv2[0]));
http://www.antlr.org/wiki/display/CS652/How+To+Read+C+Declarations