Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

What is the difference between

echo "mem" > /sys/power/state

and

pm-suspend

Both can put the computer to sleep mode. I want to execute a script automatically when the system resumes from sleep. I wrote a script and put it in /etc/pm/sleep.d. It works only when I use pm-suspend command and resume the system back. However, it has no effect on resume if I suspend the system with echo "mem" > /sys/power/state. I also noticed that pm-suspend takes a bit longer than echo "mem" ....

share|improve this question

migrated from stackoverflow.com Feb 17 '12 at 15:03

This question came from our site for professional and enthusiast programmers.

    
This is a good question. I'd like to know the difference. –  Herman Torjussen Jun 10 '12 at 11:07

1 Answer 1

Same same, but different.

On my ubuntu system pm-suspend ends up doing the same:

do_suspend() { echo -n "mem" >/sys/power/state; } 

But as you have noted pm-suspend wraps a whole lot of other stuff around the call for management of the process like logging, locking, error checking, debug and the hooks you are using.

vi /usr/sbin/pm-suspend

and

$ grep '()'  "/usr/lib/pm-utils/pm-functions"
log()
profiling() { [ "$PM_PROFILE" = "true" ]; }
        profile() {
        profile() { shift; "$@"; }
add_before_hooks() {
add_module_help() {
before_hooks()
sleep_module_help()
update_parameters()
load_hook_blacklist()
load_hook_parameters()
hook_exit_status(){
hook_ok()
_run_hook() {
        # log() changes the return value, so save it for later
        run_hook() { profile "$1:" _run_hook "$@"; }
        run_hook() { _run_hook "$@"; }
_run_hooks() {
        run_hooks() { profile "$1 $2:" _run_hooks "$@"; }
        run_hooks() { _run_hooks "$@"; }
init_logfile()
check_suspend() { [ -n "$SUSPEND_MODULE" ]; }
check_hibernate() { [ -n "$HIBERNATE_MODULE" ]; }
check_suspend_hybrid() { [ -n "$SUSPEND_HYBRID_MODULE" ]; }
check_suspend_pmu()
do_suspend_pmu()
                do_suspend() { echo -n "mem" >/sys/power/state; }
                do_suspend() { do_suspend_pmu; }
                do_suspend() { echo -n "standby" >/sys/power/state; }
        do_hibernate()
    do_suspend_hybrid() {

for even lower level, check here: http://stackoverflow.com/questions/5658170/how-ther-linux-kernel-process-the-write-to-sys-power-state

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.