From: Stefan Rompf <stefan@loplof.de>
To: linux-pm@osdl.org
Subject: [PATCH] suspend.c: make sure stdin, stdout and stderr are open
Date: Fri, 24 Mar 2006 20:13:48 +0100 [thread overview]
Message-ID: <200603242013.48811.stefan@loplof.de> (raw)
[-- Attachment #1: Type: text/plain, Size: 611 bytes --]
Hi,
recently I patched my 2.6.16 kernel to use uswsusp. Nice work, but when I
installed /usr/local/sbin/suspend into the Suse 9.3 powermanagement scripts,
I've stumbled over a bad interaction: powersaved closes all filedescriptors
before calling scripts. suspend then opens snapshot and swap device,
allocating file descriptors 0 and 1, but printfs() afterwards. Luckily, I did
not lose any data.
For robustness, suspend must make sure that these fds are open. Simple patch
to achieve this is attached. It loses the descriptors, but I don't think
that's an issue for the short running program.
Stefan
[-- Attachment #2: suspend.diff --]
[-- Type: text/x-diff, Size: 713 bytes --]
Index: suspend.c
===================================================================
RCS file: /cvsroot/suspend/suspend/suspend.c,v
retrieving revision 1.33
diff -u -p -r1.33 suspend.c
--- suspend.c 21 Mar 2006 20:44:31 -0000 1.33
+++ suspend.c 24 Mar 2006 18:55:52 -0000
@@ -831,6 +830,10 @@ int main(int argc, char *argv[])
dev_t resume_dev;
int orig_loglevel, ret = 0;
+ /* Easy way to make sure that stdin, stdout and stderr are open
+ so that later printfs wont go to our suspend partition */
+ while((unsigned)open("/dev/null", O_RDWR)<2);
+
if (get_config("suspend", argc, argv, PARAM_NO, parameters, resume_dev_name))
return EINVAL;
if (compute_checksum != 'y' && compute_checksum != 'Y')
[-- Attachment #3: Type: text/plain, Size: 0 bytes --]
next reply other threads:[~2006-03-24 19:13 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2006-03-24 19:13 Stefan Rompf [this message]
2006-03-24 20:36 ` [PATCH] suspend.c: make sure stdin, stdout and stderr are open Rafael J. Wysocki
2006-03-24 22:55 ` Rafael J. Wysocki
2006-03-25 8:20 ` Stefan Rompf
2006-03-25 10:54 ` Rafael J. Wysocki
2006-04-10 6:58 ` Stefan Seyfried
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=200603242013.48811.stefan@loplof.de \
--to=stefan@loplof.de \
--cc=linux-pm@osdl.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.