cancel
Showing results for 
Search instead for 
Did you mean: 
Ksahil
Flight Engineer
Flight Engineer
  • 542 Views

creating zombie process

Hi All,

Doing practice and creating a zombie process getting the below error.

[root@seRver3 tmp]# cat zomibe.c
#include <stdlib.h>
#include <sys/types.h>
#include <unistd.h>

int main ()
{
pid_t child_pid;

child_pid = fork ();
if (child_pid > 0) {
sleep (60);
}
else {
exit (0);
}
return 0;
}
[root@seRver3 tmp]# ls -l zomibe.c
-rwxr-xr-x. 1 root root 205 Jun 19 23:46 zomibe.c
[root@seRver3 tmp]# source zomibe.c
-bash: zomibe.c: line 5: syntax error near unexpected token `('
-bash: zomibe.c: line 5: `int main ()'
[root@seRver3 tmp]#

Ksahil_0-1687198850972.png

Please correct me or share the correct steps to practice.

Regards, Saahil

 

Labels (2)
3 Replies
Chetan_Tiwary_
Moderator
Moderator
  • 538 Views

Hi @Ksahil !

Thanks for reaching out !

Have you compiled the c program before running ? 

Ksahil
Flight Engineer
Flight Engineer
  • 533 Views

Thank you!! 

I skipped the step to compile the c program. Now it is working fine.

1. created zombie.c file.

Ksahil_0-1687199860235.png

2. Installed the GCC package.

Ksahil_1-1687199974790.png

3. Compiled the .c file.

Ksahil_2-1687200063425.png

4. On top command, showing zombie process.

Ksahil_3-1687200153083.png

5. Unable to kill the zombie process.

Ksahil_4-1687200402028.png

Regards, Saahil

Tess
Flight Engineer
Flight Engineer
  • 500 Views

100% the solution.

Sourcing in the Linux shells, only works for files written in the language of that shell.

Join the discussion
You must log in to join this conversation.