How SIGTERM signal is processed by an Android process?

1,298 views
Skip to first unread message

Yury

unread,
Aug 14, 2012, 1:15:17 PM8/14/12
to android-...@googlegroups.com
Hi all.

I try to understand now how vold works and I've found that if some volume cannot be unmounted Android detects which process holds the resources and sends to it SIGTERM Linux signal. So, maybe someone can answer and explain the following questions:
1. How do Android processes process this signal? What happens with an Android process when it receives this signal? Where can I find code that process this signal?
2. Is it possible to send this signal to system process like system_server, acore or launcher? How do they process them and how they are recovered from the incorrect state?   

Yury Zhauniarovich

unread,
Aug 14, 2012, 7:31:46 PM8/14/12
to Gabriel M. Beddingfield, android-...@googlegroups.com
Thanks for the help! I'll try to dig in these directions!

Best Regards,
Yury Zhauniarovich



On 15 August 2012 01:23, Gabriel M. Beddingfield <gabr...@gmail.com> wrote:
On 08/14/2012 12:15 PM, Yury wrote:
Hi all.

I try to understand now how vold works and I've found that if some
volume cannot be unmounted Android detects which process holds the
resources and sends to it SIGTERM Linux signal. So, maybe someone can
answer and explain the following questions:
1. How do Android processes process this signal? What happens with an
Android process when it receives this signal? Where can I find code that
process this signal?

AFAIK, Signals are handled the same as they would be on any Linux.  See http://unixhelp.ed.ac.uk/CGI/man-cgi?signal+7 which explains the default actions and such.

Processes are allowed to install their own signal handlers.  If they don't then the default actions in the link above are taken.  I'm not sure if these actions are taken by the kernel or by libc (bionic).


2. Is it possible to send this signal to system process like
system_server, acore or launcher? How do they process them and how they
are recovered from the incorrect state?

Yes, and developers regularly do this using the 'kill' command. http://linux.die.net/man/1/kill

Many of the core services (like system_server) will get automatically re-started by the init process.  Init reads the stuff in the files /init.*.rc and starts up things like this.  If they die, init respawns them.  Init is the very first program that the kernel executes after booting.

-gabriel


Gabriel M. Beddingfield

unread,
Aug 14, 2012, 6:23:03 PM8/14/12
to android-...@googlegroups.com, Yury
On 08/14/2012 12:15 PM, Yury wrote:
> Hi all.
>
> I try to understand now how vold works and I've found that if some
> volume cannot be unmounted Android detects which process holds the
> resources and sends to it SIGTERM Linux signal. So, maybe someone can
> answer and explain the following questions:
> 1. How do Android processes process this signal? What happens with an
> Android process when it receives this signal? Where can I find code that
> process this signal?

AFAIK, Signals are handled the same as they would be on any Linux. See
http://unixhelp.ed.ac.uk/CGI/man-cgi?signal+7 which explains the default
actions and such.

Processes are allowed to install their own signal handlers. If they
don't then the default actions in the link above are taken. I'm not
sure if these actions are taken by the kernel or by libc (bionic).

> 2. Is it possible to send this signal to system process like
> system_server, acore or launcher? How do they process them and how they
> are recovered from the incorrect state?

Reply all
Reply to author
Forward
0 new messages