Skip to contentSkip to conversation

Suspend-to-ram/disk signal

DISCUSSION Pascal d'Hermilly 3 participants 5 messages Nov 26, 2007 – Nov 29, 2007 ACPI

lore
Share & tools
lore
#0 lore raw

When the computer suspends and comes back does it send a signal to the running applications?

Specifically I would like to use it so a IM client will reconnect to the server instead of saying there is a timeout.

Hope someone can help me out with a tip.

//Pascal

#1 lore raw
Quoted 2 lines · Pascal d'Hermilly

When the computer suspends and comes back does it send a signal to the running applications?

No, it doesn't. Applications aren't supposed to notice the suspend.

Quoted 4 lines

Specifically I would like to use it so a IM client will reconnect to the server instead of saying there is a timeout.

Hope someone can help me out with a tip.

Your distribution surely uses some scripts that activate the kernel's suspend code. You can modify these scripts to notify your application.

Greetings,
Rafael

Signature · 1 line
"Premature optimization is the root of all evil." - Donald Knuth
#2 lore raw
Quoted 5 lines · Rafael J. Wysocki
Quoted 2 lines · Pascal d'Hermilly

When the computer suspends and comes back does it send a signal to the running applications?

No, it doesn't. Applications aren't supposed to notice the suspend.

Except, of course, when they need to notice the suspend. The clocks changed, the hardware configuration may have changed, and something certainly did happen, so "Applications aren't supposed to notice the suspend" is a naïve proposition at best. They need to *deal well* with it, instead.

ntp needs to reset everything, for example. A LOT of software really dislikes large steps in the clocks (monotonic or gettimeofday()), and misbehave. Not notifying them they need to resync themselves is part of the breakage. Multimedia applications and screen savers are often plagued by this sort of problem.

A deskptop suite trying to emulate the ThinkVantage suite in a ThinkPad might want to check that the user woke up the laptop just to eject the bay, and ask him if he wants the box to go back to sleep, and maybe even offer to do so automatically from now on.

The possibilities are endless...

Quoted 2 lines

Your distribution surely uses some scripts that activate the kernel's suspend code. You can modify these scripts to notify your application.

Which is, of course, one way to work around the issue (and probably the best one, since trying to act upon a wakeup out-of-sync with whatever said script might be doing is likely not going to be very wise).

But it would still be nice if we kicked userspace in the arse to let it know it was sleeping for a while and needs to resync, when we wake up each
userspace task. The kernel makes that information available to kthreads
for a damn good reason. Sounds like a job for a SIGCONT, but I don't know how well would that work.

Signature · 8 lines
  "One disk to rule them all, One disk to find them. One disk to bring
  them all and in the darkness grind them. In the Land of Redmond
  where the shadows lie." -- The Silicon Valley Tarot
  Henrique Holschuh
-
To unsubscribe from this list: send the line "unsubscribe linux-acpi" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
#3 lore raw
Quoted 19 lines · Henrique de Moraes Holschuh
Quoted 5 lines · Rafael J. Wysocki
Quoted 2 lines · Pascal d'Hermilly

When the computer suspends and comes back does it send a signal to the running applications?

No, it doesn't. Applications aren't supposed to notice the suspend.

Except, of course, when they need to notice the suspend. The clocks changed, the hardware configuration may have changed, and something certainly did happen, so "Applications aren't supposed to notice the suspend" is a naïve proposition at best. They need to *deal well* with it, instead.

ntp needs to reset everything, for example. A LOT of software really dislikes large steps in the clocks (monotonic or gettimeofday()), and misbehave. Not notifying them they need to resync themselves is part of the breakage. Multimedia applications and screen savers are often plagued by this sort of problem.

Quoted 6 lines

A deskptop suite trying to emulate the ThinkVantage suite in a ThinkPad might want to check that the user woke up the laptop just to eject the bay, and ask him if he wants the box to go back to sleep, and maybe even offer to do so automatically from now on.

The possibilities are endless...

OTOH, there are applications that need not be notified in any way, so I don't think we should uncondtionally send signals to all of them, for example.

Quoted 7 lines
Quoted 2 lines

Your distribution surely uses some scripts that activate the kernel's suspend code. You can modify these scripts to notify your application.

Which is, of course, one way to work around the issue (and probably the best one, since trying to act upon a wakeup out-of-sync with whatever said script might be doing is likely not going to be very wise).

Quoted 5 lines

But it would still be nice if we kicked userspace in the arse to let it know it was sleeping for a while and needs to resync, when we wake up each
userspace task. The kernel makes that information available to kthreads
for a damn good reason. Sounds like a job for a SIGCONT, but I don't know how well would that work.

It wouldn't work very well, IMHO, unless the tasks in question are prepared to get an "out of order" SIGCONT.

However, sending SIGSTOP to selected tasks before the suspend and then SIGCONT after the resume might do the trick.

Greetings,
Rafael
-
To unsubscribe from this list: send the line "unsubscribe linux-acpi" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html

#4 lore raw
Quoted 9 lines · Rafael J. Wysocki
Quoted 6 lines

A deskptop suite trying to emulate the ThinkVantage suite in a ThinkPad might want to check that the user woke up the laptop just to eject the bay, and ask him if he wants the box to go back to sleep, and maybe even offer to do so automatically from now on.

The possibilities are endless...

OTOH, there are applications that need not be notified in any way, so I don't think we should uncondtionally send signals to all of them, for example.

IMO, "need not be notified" != "must not be notified". *If* it doesn't cause trouble for the vast majority of applications, notifying them all is better.

Quoted 8 lines
Quoted 5 lines

But it would still be nice if we kicked userspace in the arse to let it know it was sleeping for a while and needs to resync, when we wake up each
userspace task. The kernel makes that information available to kthreads
for a damn good reason. Sounds like a job for a SIGCONT, but I don't know how well would that work.

It wouldn't work very well, IMHO, unless the tasks in question are prepared to get an "out of order" SIGCONT.

It is a actually a bug if anything can't take multiple SIGCONT's in a row, AFAIK. Most applications don't pay attention to SIGSTOP and SIGCONT at all anyway, and let the default handlers take care of it (and those do the right thing if they receive multiple signals).

Quoted 2 lines

However, sending SIGSTOP to selected tasks before the suspend and then SIGCONT after the resume might do the trick.

Or to all userspace tasks that are not part of the "suspend process interface" (for suspend2 UI) come to think of it, since we ARE going to freeze them anyway. I.e. "send SIGSTOP to all but some selected tasks..." :-)

Signature · 4 lines
  "One disk to rule them all, One disk to find them. One disk to bring
  them all and in the darkness grind them. In the Land of Redmond
  where the shadows lie." -- The Silicon Valley Tarot
  Henrique Holschuh