Android:tgid task_struct val

发布于 2024-11-06 18:46:13 字数 444 浏览 2 评论 0原文

我有一个守护进程,我不断启动并在循环中执行“kill -9”,以便对特定用例进行压力测试。该守护进程加载一个共享库,该库又打开一个文件描述符。 (fd的打开/关闭是在内核中处理的另一个共享库代码中)。我观察到,在内核库中进行清理操作时,它会在清理之前检查 task_structs (tgid) 中的 PID 值。 现在我的观察:我有时看到当守护进程被杀死时,我没有看到相关的 tgid 值,而是看到一个奇怪的进程 ID 值,该值是“binder 进程”。因此,我在内核代码中的清理操作不会对被“kill -9”杀死的进程 ID 生效

。任何人都知道为什么 current->tgid 值是活页夹进程的值,而不是绑定进程的值。被杀死的守护进程。请注意,我的守护进程确实链接到“libbinder”。不确定这是否会有所作为。如果我从我的守护进程中删除到“libbinder”及其相关代码的链接,一切看起来都很好

请问有什么建议/想法吗?

I have a daemon that I continuously start and do a 'kill -9' in a loop in order to stress test a particular use case. This daemon loads a shared library which in turn opens a fd. (opening / closing of fd is in another shared library code handled in kernel) . I observe that at the time of clean up operations in the kernel library, it checks for the PID value from task_structs, (tgid) before cleaning up .
Now my observation : I sometime see that when the daemon gets killed , i do not see a relevant tgid value instead i see a strange process ID value which of 'binder process'. As a result my clean up operations in the kernel code does not take in effect for that process ID that juts got killed by 'kill -9'

Any one knows why current->tgid value is that of a binder process and not of the daemon that gets killed. Note that my daemon does link to 'libbinder'. Not sure if that can make a difference. If I remove the linking to 'libbinder' and its relevant code from my daemon, everything seems fine

Any suggestions/ ideas please?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

残龙傲雪 2024-11-13 18:46:13

如果您的用户空间进程打开一个文件,然后分叉另一个进程,则打开的文件将在分叉的进程中重复(看来这个 libbinder 可能正在分叉另一个进程)。

仅当放置对文件的last引用时,才会调用内核中file_operations结构的close方法。如果两个进程大约在同一时间死亡,那么最终调用 close 方法的进程将是第二个死亡的进程。

您的内核代码不应该键入tgid。它应该将清理操作所需的数据附加到struct file而不是附加到task_struct

If your userspace process opens a file, then forks another process, the open file will be duplicated in the forked process (it appears probable that this libbinder is forking off another process).

The close method of the file_operations struct in the kernel will only be called when the last reference to the file is put. If both processes die around the same time, then the process which ends up calling the close method will be whichever one happens to die second.

Your kernel code should not be keying on tgid. It should be attaching the data required for the cleanup operations to the struct file, not to the task_struct.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文