I have got segmentation failed on my program. I have tried to create as many catch cases to find out wheres the problem and let the program successfully run. I am currently reexaminating my layers of loops to see if my programming logic is wrong (as cmdArgv will be messed up if thats wrong). I wonder if I am in the right direction of debugging, so I am asking someones help here.
Input: ls (as taken in line 65 fgets(input, 1024, stdin);)
Current output (in gdb):
(gdb) run
...
## JCshell [1086] ## ls
Program received signal SIGSEGV, Segmentation fault.
__execvpe (file=0x0, argv=0x7fffffffbc40, envp=0x7fffffffe1f8) at ./posix/execvpe.c:190
190 ./posix/execvpe.c: No such file or directory.
(gdb) print cmdArgv
No symbol "cmdArgv" in current context.
Expected output:
## JCshell [1086] ## ls // as in input
shell_prog.c a.out // as in execvp
(PID)1087 (CMD)tloop (STATE)Z (EXCODE)2 (PPID)261 (USER)2.00 (SYS)0.00 (VCTX)13 (NVCTX)2 // some status as in printProcessDetails()
My code: as in attached
Sorry if I am not clear enough or using the wrong tag. please correct me if you notice i have done something wrong in the code or/and the posting format