summaryrefslogtreecommitdiffstats
path: root/sys-utils/rtcwake.c
diff options
context:
space:
mode:
authorMarco d'Itri2009-01-25 17:44:16 +0100
committerKarel Zak2009-01-26 21:22:24 +0100
commite4b0fc36ffb565f19db8934bc13c9b6a2bce572f (patch)
tree55be219b21ec46af7f4cfe9076950b086278fa4f /sys-utils/rtcwake.c
parentnamei: don't duplicate '/' directory (diff)
downloadkernel-qcow2-util-linux-e4b0fc36ffb565f19db8934bc13c9b6a2bce572f.tar.gz
kernel-qcow2-util-linux-e4b0fc36ffb565f19db8934bc13c9b6a2bce572f.tar.xz
kernel-qcow2-util-linux-e4b0fc36ffb565f19db8934bc13c9b6a2bce572f.zip
rtcwake: support not suspending
People usually want to use pm-utils to suspend the system instead of the raw kernel interface, so I added an option to just exit after configuring the wakeup time. Actually I think that all the suspend code should be removed from rtcwake, since it does not really belong there. Signed-off-by: Marco d'Itri <md@linux.it>
Diffstat (limited to 'sys-utils/rtcwake.c')
-rw-r--r--sys-utils/rtcwake.c12
1 files changed, 8 insertions, 4 deletions
diff --git a/sys-utils/rtcwake.c b/sys-utils/rtcwake.c
index 3baf88c61..4b843736d 100644
--- a/sys-utils/rtcwake.c
+++ b/sys-utils/rtcwake.c
@@ -333,6 +333,7 @@ int main(int argc, char **argv)
|| strcmp(optarg, "mem") == 0
|| strcmp(optarg, "disk") == 0
|| strcmp(optarg, "on") == 0
+ || strcmp(optarg, "no") == 0
) {
suspend = strdup(optarg);
break;
@@ -419,7 +420,8 @@ int main(int argc, char **argv)
devname = new_devname;
}
- if (strcmp(suspend, "on") != 0 && !is_wakeup_enabled(devname)) {
+ if (strcmp(suspend, "on") != 0 && strcmp(suspend, "no") != 0
+ && !is_wakeup_enabled(devname)) {
fprintf(stderr, _("%s: %s not enabled for wakeup events\n"),
progname, devname);
exit(EXIT_FAILURE);
@@ -451,16 +453,18 @@ int main(int argc, char **argv)
if (setup_alarm(fd, &alarm) < 0)
exit(EXIT_FAILURE);
- sync();
printf(_("%s: wakeup from \"%s\" using %s at %s\n"),
progname, suspend, devname,
ctime(&alarm));
fflush(stdout);
usleep(10 * 1000);
- if (strcmp(suspend, "on") != 0)
+ if (strcmp(suspend, "no") == 0)
+ exit(EXIT_SUCCESS);
+ else if (strcmp(suspend, "on") != 0) {
+ sync();
suspend_system(suspend);
- else {
+ } else {
unsigned long data;
do {