LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   kill -3 pid > /tmp/process.txt not working? (https://www.linuxquestions.org/questions/linux-newbie-8/kill-3-pid-tmp-process-txt-not-working-4175539266/)

gdizzle 04-09-2015 07:51 PM

kill -3 pid > /tmp/process.txt not working?
 
Hi All,
I am trying to get a dump of a process using kill and it doesn't look to be working, can someone explain what I am doing wrong?

Code:

systemctl start snmpd.service
Code:

pgrep snmpd
4233

Code:

kill -3 4233 > /tmp/snmp_pid.txt
OR

Code:

kill -SIGQUIT 4233 > /tmp/snmp_pid.txt
Yes the process quit's which is fine but there is no output from the process in /tmp/snmp_pid.txt.

Can someone please explain?

Thanks

veerain 04-09-2015 11:58 PM

The kill command justs send a signal to process. It's upto the process to produce some messages.

gdizzle 04-10-2015 12:31 AM

Can I get a process where this would be a good example? Or is JAVA the only one from what I can see online?

pan64 04-10-2015 12:44 AM

what do you expect? what should be put into that file?

gdizzle 04-10-2015 12:48 AM

Thats what I wish to see pan64 an example of what's in there? How it's used for debugging.

I understand different applications would have different results. Show me an example.

pan64 04-10-2015 12:50 AM

In general nothing. That construct is not useful at all (but obviously it is only my own opinion). That's why I asked.

gdizzle 04-10-2015 12:52 AM

Can someone show me an example, I cannot find an application that replies to kill -3 ?

unSpawn 04-10-2015 01:30 AM

No idea what you're trying to troubleshoot exactly but if you're not suspecting trouble with systemd itself, why not configure the process for debug / verbose mode, start the process with 'strace' (see 'man strace') from the command line redirecting output to text files, then kill it and then look at its log file and strace logs?

gdizzle 04-10-2015 01:45 AM

I have a rouge java process running wild, http://javaeesupportpatterns.blogspo...-high-cpu.html, I have tested on my other servers which run WAS kill -3 and I had no process dumps, I have also tested other applications for kill -3, hoping to get an idea of what the output should look like so I can debug it as explained in the article.


I will eventually kill the process, but I was after a process dump for output, I could install jstack and other tools but, things get "political" so I am trying to use the current tools on the troublesome system.

It would be nice to use kill -3, for it but looks like the application does not respond to it..., would be good but nobody can replicate the issue hence why I am leaving this thing running until I can guarantee i get decent output. The application has been running since January and nobody noticed it and the logs have been rotated long ago.

I have looked inside the pid / child pid for more information but cmdline output cannot be decoded into which webcontainer id hence I was looking into the article pasted.

In the meantime I thought I would give kill -3 a try as I have never used it or seen it work.

will look deeper into strace.

pan64 04-10-2015 02:05 AM

It seems you think kill -3 will produce a core. But actually kill itself does not do that, it only sends the signal to the process. The core probably will be created, by the kernel, and not the kill command itself. You are not able to specify the location of the core file by that redirection.
That's why I asked you to explain what do you really expect. Is that a core file?

jpollard 04-10-2015 04:26 PM

If you are expecting to get a core dump of the process, that is NOT the way to do it.

First the process must be running with ulimits that permit a dump to be created (see man page on ulimit, normally core dumps are disabled).

Second, when the signal is given to the process, a core dump will be written... if and only if the working directory is writable by the process. I believe the usual name is Core.<pid> (uppercase C, but it has been a while).

For a Java program, a core dump is not that useful - the information in it is more related to the JVM, and tracing out what the application was doing in the first place gets tricky. Normally such debugging would be done through an IDE such as Eclipse. Of course, if you are debugging the JVM I suspect otherwise, but am now out of my depth.

gdizzle 04-12-2015 06:20 PM

I am after a Thread Dump as specified here : http://javaeesupportpatterns.blogspo...-high-cpu.html

Point 2, generate a thread dump, using kill -3.

core dump: a dump of the contents of main memory, carried out typically as an aid to debugging.

thread dump: is a list of all the Java threads that are currently active in a Java Virtual Machine (JVM).

- As explained here:

http://stackoverflow.com/questions/1...of-thread-dump

Now thread dumps should be able to be made with
Code:

kill -3 pid > thread_dump.txt
or
Code:

kill -s SIGQUIT pid > thread_dump.txt

Nothing specified here from Redhat about the Ulimits, so I am thinking the core dumps, (memory) are specified different from thread dumps.

https://access.redhat.com/solutions/18178


I haven't seen a thread dump yet, with kill has someone got this working?

looks like jstack might be the option.

pan64 04-13-2015 12:21 AM

Based on the link you posted this is a special feature of jvm (to produce a thread dump on kill -3). It was also mentioned dump is put into a logfile or in a separate file. That is defined by the jvm, and you cannot specify the output using the kill command.
You can try strace -f strace.log <your java app>, execute kill -3 and check that log. You will need to find to location of the dump in that strace.log

gdizzle 04-13-2015 01:15 AM

Thanks Pan, this looks like a closer win to seeing whats going on.

Code:

strace -f -p 14324 -o /tmp/java_pid.txt


All times are GMT -5. The time now is 11:47 AM.