Riorita Riorita - 10 months ago 112
C Question

phtread_kill() Segmentation fault (core dumped)

I have a list of java threads

top -H -p [java ppid number]
and want to kill certain with pthread_kill() by C call

#include <sys/types.h>
#include <signal.h>
#include <stdio.h>
#include <linux/unistd.h>
#include <errno.h>
#include <unistd.h>
#include <pthread.h>

int main(void)
return 0;

Compiling like this

sudo gcc ckill.c -o comp -pthread


Segmentation fault (core dumped)

What's wrong?

usr usr
Answer Source

pthread_kill() can send a signal to a thread within the same process. And for that reason, it takes a pthread_t as an argument, not a PID. So you can't send signals to some java process as you are doing.

If you want to send a signal to any process on the system, have a look at kill().