Of course, there's no deadlock, and you can send a signal that he's producing core files.
1 first to understand the signal
Signal Description Signal number on Linux x86[1]
SIGABRT Process aborted 6
Sigalrm Signal raised by alarm 14
Sigbus Bus Error: "Access to undefined portion of memory object" 7
SIGCHLD child process terminated, stopped (or continued*) 17
Sigcont Continue If stopped 18
SIGFPE floating point exception: "Erroneous arithmetic operation" 8
Sighup Hangup 1
Sigill Illegal Instruction 4
SIGINT Interrupt 2
SIGKILL Kill (terminate immediately) 9
Sigpipe Write to pipe with no one reading 13
Sigquit Quit and dump Core 3
SIGSEGV Segmentation violation 11
SIGSTOP Stop executing temporarily 19
Sigterm Termination (Request to terminate) 15
SIGTSTP Terminal Stop Signal 20
Sigttin Background process attempting to read from TTY ("in") 21
Sigttou Background Process attempting to write to TTY (' out ') 22
SIGUSR1 user-defined 1 10
SIGUSR2 user-defined 2 12
Sigpoll pollable Event 29
Sigprof Profiling Timer Expired 27
Sigsys Bad Syscall 31
Sigtrap Trace/breakpoint Trap 5
Sigurg Urgent data available on socket 23
SIGVTALRM Signal raised by timer counting virtual time: "Virtual timer expired" 26
SIGXCPU CPU time limit exceeded 24
Sigxfsz File size limit exceeded 25
Allows the process to produce a segment error, generating a signal to the core file
SIGABRT Process aborted 6
2 Use Method:
Like the a.out process ID number 1234.
After the a.out is executed, a new session end is opened.
Kill-Signal Number process ID
Executive Kill-6 1234
Core will be immediately generated
3. Examples
Use Ulimit-c First
See if the shell limits the build size of the core
Perform Ulimit-c Unlimited
Do not limit core size
Compile the program (the end of the article will present the code), remember to add-g
GCC new0001.c-g-lpthread-o a.out
Execute./a.out
New Meeting session
root@ubuntu:~# ps-aux| grep a.out
Root 16606 45.5 0.1 43320 696 pts/4 sl+ 00:14.0:04
Root 16613 0.0 0.3 4540 1928 PTS/6 s+ 00:14 0:00 grep--color=auto a.out
root@ubuntu:~#
root@ubuntu:~#
root@ubuntu:~#
root@ubuntu:~# kill-6 16606
root@ubuntu:~#
./a.out Process Terminated
root@ubuntu:/share#./a.out
Aborted (core dumped)
root@ubuntu:/share#
Using GDB to view core files
root@ubuntu:/share#
root@ubuntu:/share# gdb a.out Core
GNU gdb (Ubuntu 7.10-1ubuntu2) 7.10
Copyright (C) 2015 free Software Foundation, Inc.
License gplv3+: GNU GPL version 3 or later
This is the free software:you are and redistribute it.
There is NO WARRANTY and to the extent permitted by. Type "Show copying"
and "Show warranty" for details.
This is GDB was configured as "I686-linux-gnu".
Type ' show configuration ' for configuration details.
For bugs reporting instructions, please:
Find the GDB manual and other documentation resources online at:
For help, type ' help '.
Type ' apropos word ' to ' search for commands related to Word ...
Reading symbols from A.out...done.
Warning:exec file is newer than core file.
[New LWP 16551]
[New LWP 16552]
[New LWP 16553]
[New LWP 16554]
[New LWP 16555]
[Thread debugging using libthread_db enabled]
The Using host libthread_db the Library "/lib/i386-linux-gnu/libthread_db.so.1".
Core is generated by './a.out '.
Program terminated with signal SIGABRT, aborted.
#0 0xb775dbe8 in __kernel_vsyscall ()
[Current thread is 1 (thread 0xb7569700 (LWP 16551))]
(GDB) Info threads
ID Target ID Frame
5 Thread 0XB5D65B40 (LWP 16555) 0xb775dbe8 in __kernel_vsyscall ()
4 Thread 0XB6566B40 (LWP 16554) 0xb775dbe8 in __kernel_vsyscall ()
3 Thread 0XB6D67B40 (LWP 16553) 0xb775dbe8 in __kernel_vsyscall ()
2 Thread 0XB7568B40 (LWP 16552) 0xb775dbe8 in __kernel_vsyscall ()
* 1 Thread 0xb7569700 (LWP 16551) 0xb775dbe8 in __kernel_vsyscall ()
(GDB)
4. Code
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <pthread.h >
#include <unistd.h>
pthread_mutex_t G_smutex;
void * Func (void *arg)
{
int i=0;
Lock
Pthread_mutex_lock (&g_smutex);
for (i = 0; i < 0x7fffffff. i++)
{
}
//forget unlock return
NULL;
}
int main ()
{
pthread_t thread_id_01;
pthread_t thread_id_02;
pthread_t thread_id_03;
pthread_t thread_id_04;
pthread_t thread_id_05;
Pthread_mutex_init (&g_smutex, NULL);
Pthread_create (&thread_id_01, NULL, func, NULL);
Pthread_create (&thread_id_02, NULL, func, NULL);
Pthread_create (&thread_id_03, NULL, func, NULL);
Pthread_create (&thread_id_04, NULL, func, NULL);
Pthread_create (&thread_id_05, NULL, func, NULL);
while (1)
{sleep
(0XFFF);
}
return 0;
}