Linux - NewbieThis Linux forum is for members that are new to Linux.
Just starting out and have a question?
If it is not in the man pages or the how-to's this is the place!
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
The signals listed below may be available for use with kill. When known constant, numbers and default behavior are shown.
Name Num Action Description
0 0 n/a exit code indicates if a signal may be sent
So, it does nothing, but the exit code of your "kill -0 PID" command just returns 0 if you can send a signal to PID, and returns 1 if you can't (don't have access or invalid PID)
i have check many sites but the answer is same if the PID found it comes back to KONSOLE.... i want detailed answer
But reading the man-page for kill could have saved you hours
of searching (or posting, for that matter) ;) ...
Quote:
Code:
man kill
SIGNALS
The signals listed below may be available for use with kill. When
known constant, numbers and default behavior are shown.
Name Num Action Description
0 0 n/a exit code indicates if a signal may be sent
But reading the man-page for kill could have saved you hours
of searching (or posting, for that matter) ...
It's needless snarkiness like this that turns off many noobs and non-native speakers of English. If you really wanted to help, you could show him how to use a return code from "kill -0" in a script to determine the existence or non-existence of a process.
There is just a handful of man pages written with the end user in mind. The huge majority are shorthand for fellow coders.
Distribution: Slackware (mainly) and then a lot of others...
Posts: 855
Rep:
man pages for common commands (man 1 i.e man section 1) are understandable to anyone (unless there is a language problems) and I think it should work.
some man pages (eg man 2 or man 3) definately need some technical know-how and for that you can post here.
man pages for common commands (man 1 i.e man section 1) are understandable to anyone (unless there is a language problems) and I think it should work.
some man pages (eg man 2 or man 3) definately need some technical know-how and for that you can post here.
As you are new to linux.keep these things always in practice.
(1) man pages (to know about what commands can do)
(2) check the logs (in troubleshooting)
I don't think that I got any wiser from reading the man page. Probably just me that thinks that I'm always allowed to (may) send a signal to a process. I mean, I can type the command kill -9 pid and press <enter>; the OS might not allow me to kill a process (or whatever), but it will tell me that when I issue the command; so why kill -0 pid first?
Below how I see that it can be used and it's a total waste of cpu cycles.
Code:
kill -0 pid && kill -9 pid
I agree that this thread should not have been woken up, but now it's alive again I like to know why kill -0 pid exists?
I think I finally figured out an example for myself that might be useful (but it took a while)
Code:
kill -0 $1
if [ $? -eq 1 ]; then
echo "no permission to signal pid $1, script terminated"
exit
fi
...
...
...
kill appropriate_signal_depending_on_process $1
The dots can be a modification of a config file for a background process; the 'kill' will inform the process that it needs to read the config again.
I think its there to differentiate between processes you can't signal because you don't have access/auth eg they are not yours (doesn't apply to root ) and processes you get a failure on because it either doesn't have a handler for that signal, or its incorrectly written.
Sorry to resurrect this again, but another possible use for "kill -0" (or more likely the system API equivalent) is to check the existence of a process before communicating with it in another way - e.g.
If service X writes its process ID into /var/run/X.pid, then you can use 'kill -0 `cat /var/run/X.pid`' to determine if the process for X is still running.
There are obviously other ways of doing it (e.g. checking for the PID in /proc, or using grep on the output of PS), but they are probably less elegant
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.