Hi everyone
I am writing a simple shell but the background '&' not working i dont understand
this is my fork
pid_t pid;
pid=fork\(\);
if\(pid<0\)
\{
printf\("\\nChild process failed."\);
exit\(1\);
\}
else if\(pid==0\)
\{
if\(execvp\(argv[0],argv\)<0\)
\{
printf\("command not found.\\n"\);
exit\(1\);
\}
\}
else if\(background==1\)
\{
pid = waitpid\(pid, NULL, 1\);
if \(pid > 0\)
printf\("working %d\\n", pid\);
\}
and this is my seaching key '&' code
printf("");
gets(inputBuffer);
strcpy\(history[j\+\+],inputBuffer\);
parse\(inputBuffer,argv\);
if \(strcmp\(argv[0], "exit"\) == 0\)
exit\(0\);
zzz=strchr\(inputBuffer,'&'\);
if\(zzz!=NULL\)\{
background=1;
\}
else \{
background=0;
\}
who help me ?