1847104 Members
5194 Online
110263 Solutions
New Discussion

Defunct Process

 
SOLVED
Go to solution
zap_2
Advisor

Defunct Process

Hi Unix Gurus,

Can ordinary users produce defunct process?
Thanks in advance.....
13 REPLIES 13
Steven E. Protter
Exalted Contributor

Re: Defunct Process

Yes.

They merely need to have minimal programming skills and be not careful. Usually however, root can kill these processes.

SEP
Steven E Protter
Owner of ISN Corporation
http://isnamerica.com
http://hpuxconsulting.com
Sponsor: http://hpux.ws
Twitter: http://twitter.com/hpuxlinux
Founder http://newdatacloud.com
Arunvijai_4
Honored Contributor

Re: Defunct Process

Yes, Anyone can create defunct process.

-Arun
"A ship in the harbor is safe, but that is not what ships are built for"
zap_2
Advisor

Re: Defunct Process

Can any one show me how to create defunct process?Thanks in advance ...
Muthukumar_5
Honored Contributor

Re: Defunct Process

Yes. Simple coding will make process like that. Applications which is running in normal user will create defunct process also.

hth.
Easy to suggest when don't know about the problem!
Arunvijai_4
Honored Contributor
Solution

Re: Defunct Process

Here is a small C code to create defunct,

#include
main()
{
int pid;
pid=fork(); /* Duplicate */
if (pid!=0) /* Branch based on return value from fork() */
{
while (1)
sleep(1000);
}
else
{
exit(42);
}
}

[root@mysystem tmp]# gcc -o fork fork.c
[root@mysystem tmp]# ./fork &
[1] 6823

[root@mysystem tmp]# ps
PID TTY TIME CMD
6764 pts/0 00:00:00 bash
6823 pts/0 00:00:00 fork
6824 pts/0 00:00:00 fork
6825 pts/0 00:00:00 ps
"A ship in the harbor is safe, but that is not what ships are built for"
Arunvijai_4
Honored Contributor

Re: Defunct Process

I tried in Linux, not on HP-UX since i dont have a compiler installed in my HP-UX. Anyways, it should work.

-Arun
"A ship in the harbor is safe, but that is not what ships are built for"
zap_2
Advisor

Re: Defunct Process

Hi Arun,
How to compile your script in hpux?
Arunvijai_4
Honored Contributor

Re: Defunct Process

# cc -o fork fork.c
# fork &
# ps

-Arun
"A ship in the harbor is safe, but that is not what ships are built for"
zap_2
Advisor

Re: Defunct Process

# cc fork fork.c
cc: warning 485: Can't open "fork.c".
Arunvijai_4
Honored Contributor

Re: Defunct Process

It should be # cc -o fork fork.c, assuming that you have fork.c in your current directory. Otherwise, you need to give full path to fork.c

-Arun
"A ship in the harbor is safe, but that is not what ships are built for"
Raj D.
Honored Contributor

Re: Defunct Process

Hi Zap ,

Try ,

# cc fork.c -o fork

-o defines the output compiled file.
For details check # man cc


Cheers,
Raj.
" If u think u can , If u think u cannot , - You are always Right . "
zap_2
Advisor

Re: Defunct Process

many thanks unix gurus .........
Vibhor Kumar Agarwal
Esteemed Contributor

Re: Defunct Process

Defunct process is a process which has terminated but the signal hasn't been send to the parent.

So it has nothing to do with a user.
Either you can create it or you run an application which is not programmed correctly.
Vibhor Kumar Agarwal