I know that you will rap me over the knuckles but.
Why does it make Segmentation fault
char* cmd; strcpy(cmd, argv[0]);
when this d
If you want to make copy of argv[0] easily,
char* cmd = strdup(argv[0]);
Of course, you have better to check result of strdup is null or not. :)