Quantcast
Channel: Active questions tagged linux-kernel - Stack Overflow
Viewing all articles
Browse latest Browse all 12244

Can a Linux process/thread terminate without pass through do_exit()?

$
0
0

To verify the behavior of a third party binary distributed software I'd like to use, I'm implementing a kernel module whose objective is to keep track of each child this software produces and terminates.

The target binary is a Golang produced one, and it is heavily multi thread.The kernel module I wrote installs hooks on the kernel functions _do_fork() and do_exit() to keep track of each process/thread this binary produces and terminates.

The LKM works, more or less.

During some conditions, however, I have a scenario I'm not able to explain.It seems like a process/thread could terminate without passing through do_exit().

The evidence I collected by putting printk() shows the process creation but does not indicate the process termination.

I'm aware that printk() can be slow, and I'm also aware that messages can be lost in such situations.

Trying to prevent message loss due to slow console (for this particular application, serial tty 115200 is used), I tried to implement a quicker console, and messages have been collected using netconsole.

The described setup seems to confirm a process can terminate without pass through the do_exit() function.

But because I wasn't sure my messages couldn't be lost on the printk() infrastructure, I decided to repeat the same test but replacing printk() with ftrace_printk(), which should be a leaner alternative to printk().

Still the same result, occasionally I see processes not passing through the do_exit(), and verifying if the PID is currently running, I have to face the fact that it is not running.

Also note that I put my hook in the do_exit() kernel function as the first instruction to ensure the function flow does not terminate inside a called function.

My question is then the following:

Can a Linux process terminate without its flow pass through the do_exit() function?

If so, can someone give me a hint of what this scenario can be?


Viewing all articles
Browse latest Browse all 12244

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>