which signal is sent to freeze process?
Quoted 8 lines · Manfred Spraul
Quoted 7 lines · Rafael
Quoted 2 lines · Lomesh
The other problem I am facing that read from socket returns with ENODATA when resuming. any ideas?
It's of similar kind: the system call checks
signal_pending(current)and exit with an error if that's true.
Quoted 6 lines
Quoted 3 lines
Well, I'm afraid we can't place
try_to_freeze()in every system call that does something like that ...I don't understand why the
poll()system call returns to user space.poll()uses ERESTARTNOHAND, thus it should not return to user space. Any ideas why ERESTARTNOHAND doesn't work?
Well, look at the code in fs/select.c:do_poll() . If signal_pending(current) is true, the main loop breaks and count is returned to do_sys_poll(). If zero is returned and signal_pending(current) is still true, do_sys_poll() returns -EINTR.
Greetings,
Rafael
Signature · 1 line
"Premature optimization is the root of all evil." - Donald Knuth
Quoted 6 lines · Rafael J. Wysocki
Well, look at the code in fs/select.c:do_poll() . If
signal_pending(current)is true, the main loop breaks and count is returned todo_sys_poll(). If zero is returned andsignal_pending(current)is still true,do_sys_poll()returns-EINTR.
Thanks - I looked at sys_ppoll().sys_ppoll() and select() use ERESTARTNOHAND, sys_poll uses EINTR.
--
Manfred
Quoted 10 lines · Rafael
Quoted 2 lines · Lomesh
The other problem I am facing that read from socket returns with ENODATA when resuming. any ideas?
It's of similar kind: the system call checks
signal_pending(current)and exit with an error if that's true.Well, I'm afraid we can't place
try_to_freeze()in every system call that does something like that ...
I don't understand why the poll() system call returns to user space. poll() uses ERESTARTNOHAND, thus it should not return to user space. Any ideas why ERESTARTNOHAND doesn't work?
--
Manfred
Quoted 4 lines
Hi!
Can you generate small testcase that demonstrates the problem?
Quoted 8 lines
Quoted 4 lines
Then what would be the correct way to handle resume process. The other way of course is to make all the applications check the errno in case of failure. But that seems more more problematic then system call checking. What do you say?
Hmm, does that testcase behave correctly over SIGSTOP/SIGCONT? I'm not saying kernel behaves nicely here, but perhaps fixing the apps to check errno properly is the right thing to do? :-)
Perhaps the kernel should use ERESTARTNOHAND instead of EINTR?
The current code is more than odd:
- select() and sys_ppoll() both use ERESTARTNOHAND (i.e.: the functions do not return to user space with SIGSTOP/SIGCONT or freezer())
- sys_poll() uses EINTR (i.e.: SIGSTOP/SIGCONT/freezer() return to user space)
Attached is a patch that switches sys_poll to ERESTARTNOHAND and a poll test app. Boot tested with FC6.
What do you think? With ERESTARTNOHAND, poll would only return to user space if the app has a SIGCONT handler installed.
--
Manfred
fs/select.c +2 -3
@@ -723,7 +723,7 @@ } err = fdcount;if (!fdcount &&signal_pending (current)) - err = -EINTR ; + err = -ERESTARTNOHAND ; out_fds: walk = head;while (walk!=NULL ) {
@@ -794,7 +794,7 @@ ret =do_sys_poll (ufds, nfds, &timeout);/* We can restart this syscall, usually */ -if (ret == -EINTR ) { +if (ret == -ERESTARTNOHAND ) {/* * Don't restore the signal mask yet. Let do_signal() deliver * the signal on the way back to userspace, before the signal
@@ -805,7 +805,6 @@ sizeof(sigsaved));set_thread_flag (TIF_RESTORE_SIGMASK ); } - ret = -ERESTARTNOHAND ; }else if (sigmask)sigprocmask (SIG_SETMASK , &sigsaved,NULL );
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <sys/poll.h>
#include <sys/time.h>
#include <sys/resource.h>
#include <errno.h>
int main(int argc, char **argv)
{
int delay, ret;
struct pollfd pfd;
int pipesfd[2];
printf("sp <delay>\n");
if (argc != 2)
return 1;
delay = atoi(argv[1]);
printf("delay %d.\n", delay);
if (delay < 0 || delay > 1000)
return 2;
if (pipe(pipesfd) != 0) {
fprintf(stderr, "pipe failed with errno %d.\n", errno);
return 3;
}
pfd.fd = pipesfd[0];
pfd.events = POLLIN;
if (!fork()) {
sleep(delay);
write(pipesfd[1], "", 1);;
return 0;
}
sleep(1);
ret = poll(&pfd, 1, -1);
printf("poll returned %d.\n", ret);
if (pfd.revents)
printf(" events %8xh revents %8xh.\n", pfd.events, pfd.revents);
return 0;
}Quoted 17 lines · Manfred Spraul
Quoted 4 lines
Hi!
Can you generate small testcase that demonstrates the problem?
Quoted 8 lines
Quoted 4 lines
Then what would be the correct way to handle resume process. The other way of course is to make all the applications check the errno in case of failure. But that seems more more problematic then system call checking. What do you say?
Hmm, does that testcase behave correctly over SIGSTOP/SIGCONT? I'm not saying kernel behaves nicely here, but perhaps fixing the apps to check errno properly is the right thing to do? :-)
Perhaps the kernel should use ERESTARTNOHAND instead of EINTR? The current code is more than odd:
-select()andsys_ppoll()both use ERESTARTNOHAND (i.e.:
the functions do not return to user space with SIGSTOP/SIGCONT orfreezer())
Quoted 6 lines
-
sys_poll()uses EINTR (i.e.: SIGSTOP/SIGCONT/freezer() return to user space)Attached is a patch that switches
sys_pollto ERESTARTNOHAND and a poll test app. Boot tested with FC6.What do you think? With ERESTARTNOHAND, poll would only return to user space if the app has a SIGCONT handler installed.
Well, I don't know why sys_poll() uses EINTR, so I don't know if that's not for a reason. Using ERESTARTNOHAND instead of it seems to be a good idea, though.
Greetings,
Rafael
Signature · 1 line
"Premature optimization is the root of all evil." - Donald Knuth
This patch works for me too.
-----Original Message-----
From: Manfred Spraul [mailto:[email protected]]
Sent: Tuesday, July 24, 2007 11:49 AM
To: Pavel Machek
Cc: Rafael J. Wysocki; [email protected]; Agarwal, Lomesh; Nigel Cunningham
Subject: Re: which signal is sent to freeze process?
Quoted 5 lines
Hi!
Can you generate small testcase that demonstrates the problem?
Quoted 1 line
Then what would be the correct way to handle resume process. The
other
Quoted 1 line
Quoted 1 line
way of course is to make all the applications check the errno in
case of
Quoted 1 line
Quoted 1 line
failure. But that seems more more problematic then system call
checking.
Quoted 5 lines
Quoted 1 line
What do you say?
Hmm, does that testcase behave correctly over SIGSTOP/SIGCONT? I'm not saying kernel behaves nicely here, but perhaps fixing the apps to check errno properly is the right thing to do? :-)
Perhaps the kernel should use ERESTARTNOHAND instead of EINTR? The current code is more than odd:
- select() and sys_ppoll() both use ERESTARTNOHAND (i.e.:
the functions do not return to user space with SIGSTOP/SIGCONT or freezer())
- sys_poll() uses EINTR (i.e.: SIGSTOP/SIGCONT/freezer() return to user space)
Attached is a patch that switches sys_poll to ERESTARTNOHAND and a poll test app.
Boot tested with FC6.
What do you think? With ERESTARTNOHAND, poll would only return to user space if the app has a SIGCONT handler installed.
--
Manfred
Hi!
Quoted 18 lines
Quoted 10 lines
Can you generate small testcase that demonstrates the problem?
Quoted 4 lines
Then what would be the correct way to handle resume process. The other way of course is to make all the applications check the errno in case of failure. But that seems more more problematic then system call checking. What do you say?
Hmm, does that testcase behave correctly over SIGSTOP/SIGCONT? I'm not saying kernel behaves nicely here, but perhaps fixing the apps to check errno properly is the right thing to do? :-)
Perhaps the kernel should use ERESTARTNOHAND instead of EINTR? The current code is more than odd:
-select()andsys_ppoll()both use ERESTARTNOHAND (i.e.:
the functions do not return to user space with SIGSTOP/SIGCONT orfreezer())-
sys_poll()uses EINTR (i.e.: SIGSTOP/SIGCONT/freezer() return to user space)
Quoted 6 lines
Attached is a patch that switches
sys_pollto ERESTARTNOHAND and a poll test app.
Boot tested with FC6.What do you think? With ERESTARTNOHAND, poll would only return to user space if the app has a SIGCONT handler installed.
I think the patch looks okay... but I expected some discussoin here and it did not happen :-(. Can you try to send it to andrew?
Quoted 28 lines
fs/select.c +2
-3@@ -723,7 +723,7 @@ } err = fdcount;if (!fdcount &&signal_pending (current)) - err = -EINTR ; + err = -ERESTARTNOHAND ; out_fds: walk = head;while (walk!=NULL ) {@@ -794,7 +794,7 @@ ret =do_sys_poll (ufds, nfds, &timeout);/* We can restart this syscall, usually */ -if (ret == -EINTR ) { +if (ret == -ERESTARTNOHAND ) {/* * Don't restore the signal mask yet. Let do_signal() deliver * the signal on the way back to userspace, before the signal @@ -805,7 +805,6 @@ sizeof(sigsaved));set_thread_flag (TIF_RESTORE_SIGMASK ); } - ret = -ERESTARTNOHAND ; }else if (sigmask)sigprocmask (SIG_SETMASK , &sigsaved,NULL );
Signature · 2 lines
(english) http://www.livejournal.com/~pavelmachek (cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html