summaryrefslogtreecommitdiffstats
path: root/sys-utils/rtcwake.c
diff options
context:
space:
mode:
authorKarel Zak2010-04-08 08:51:00 +0200
committerKarel Zak2010-04-08 08:51:00 +0200
commitecd55f9647d139784857df994d0f5b965d164547 (patch)
treebf7468074caf638693e093652d6e5342ed71f359 /sys-utils/rtcwake.c
parentswaplabel: fix typo in man page (diff)
downloadkernel-qcow2-util-linux-ecd55f9647d139784857df994d0f5b965d164547.tar.gz
kernel-qcow2-util-linux-ecd55f9647d139784857df994d0f5b965d164547.tar.xz
kernel-qcow2-util-linux-ecd55f9647d139784857df994d0f5b965d164547.zip
rtcwake: does miss the "off" option
Reported-by: Piergiorgio Sartor <piergiorgio.sartor@nexgo.de> Addresses: https://bugzilla.redhat.com/show_bug.cgi?id=580296 Signed-off-by: Karel Zak <kzak@redhat.com>
Diffstat (limited to 'sys-utils/rtcwake.c')
-rw-r--r--sys-utils/rtcwake.c24
1 files changed, 19 insertions, 5 deletions
diff --git a/sys-utils/rtcwake.c b/sys-utils/rtcwake.c
index 7b2df26ab..344fed76b 100644
--- a/sys-utils/rtcwake.c
+++ b/sys-utils/rtcwake.c
@@ -468,15 +468,19 @@ int main(int argc, char **argv)
fflush(stdout);
usleep(10 * 1000);
- if (strcmp(suspend, "no") == 0)
+ if (strcmp(suspend, "no") == 0) {
+ if (verbose)
+ printf(_("suspend mode: no; leaving\n"));
+ close(fd);
exit(EXIT_SUCCESS);
- else if (strcmp(suspend, "on") != 0) {
- sync();
- suspend_system(suspend);
+
} else if (strcmp(suspend, "off") == 0) {
char *arg[4];
int i = 0;
+ if (verbose)
+ printf(_("suspend mode: off; executing %s\n"),
+ _PATH_SHUTDOWN);
arg[i++] = _PATH_SHUTDOWN;
arg[i++] = "-P";
arg[i++] = "now";
@@ -487,9 +491,13 @@ int main(int argc, char **argv)
fprintf(stderr, _("%s: unable to execute %s: %s\n"),
progname, _PATH_SHUTDOWN, strerror(errno));
rc = EXIT_FAILURE;
- } else {
+
+ } else if (strcmp(suspend, "on") == 0) {
unsigned long data;
+ if (verbose)
+ printf(_("suspend mode: on; reading rtc\n"));
+
do {
t = read(fd, &data, sizeof data);
if (t < 0) {
@@ -499,6 +507,12 @@ int main(int argc, char **argv)
if (verbose)
printf("... %s: %03lx\n", devname, data);
} while (!(data & RTC_AF));
+
+ } else {
+ if (verbose)
+ printf(_("suspend mode: %s; suspending system\n"), suspend);
+ sync();
+ suspend_system(suspend);
}
if (ioctl(fd, RTC_AIE_OFF, 0) < 0)