For an application that will probably never come to see the light of day I
wanted to detect the power on (resume) event. Thanks to Darryl Okahata who responded
to my inital query on the Zaurus developer mailing list (email@example.com).
There does not appear to be a suspend event, this may seem harsh or even unwise
but really this makes sense as you probably want the system to simply turn off,
not to wait while a poorly written app tidies up after itself. So we are left
with the resume event.
When the Zaurus is powered on all process that are running receive the SIGCONT
signal.The following code tests this. All it aims to do is prove that the SIGCONT
is generated and that it is received upon resume.
/* first include the relevent headers */
/* define a signal handler see signal(2) fro more details */
/* In this case for the given signal signum, get the present time print it along with the signal number */
/* reinstate the handler for the next time and return */
void handler(int signum)
fprintf(stderr, "Time now is %s", ctime(&tim));
fprintf(stderr, "received signal %d\n", signum);
/* finally the simplest little main to activeate the thing */
/* set up the signal handler across a range of signals, this was done to check whether anything other */
/* than SIGCONT occurred (it doesn't) */
/* then loop forever printing the current time and sleepiong for a second */
int main(int argc, char *argv)
fprintf(stderr, "Time is %s\n", ctime(&tim));
Compiling this and running it in a console on the Z will clearly show timestamps
ticking away every second until the shutdown. Upon resume (some time later)
the signal will be received and the time logged along with the signal number
(18), the normal loop now continues. The timestamp logged alongside the SIGCONT
clearly shows that the signal was received immediately upon resume.