Messages in this thread | | | Date | Tue, 6 Aug 2002 15:04:47 +0200 | From | "Udo A. Steinberg" <> | Subject | Re: context switch vs. signal delivery [was: Re: Accelerating user mode |
| |
On Tue, 06 Aug 2002 08:53:24 -0400 Jeff Dike <jdike@karaya.com> wrote:
> > On iret it would have to change ownership of the socket to another > > task, i.e. process with kernel_pid wants to set task_pid as the owner > > of the socket. The above code fragment doesn't permit this, as far as > > I can see. > > Why not? There is nothing there that prevents that.
In the following code the parent (i.e. kernel) tries to set the child (i.e. task) as owner for the socket. Does this work for you? It doesn't for me, for the reason I described earlier.
#include <sys/types.h> #include <sys/socket.h> #include <fcntl.h> #include <unistd.h>
int main (void) {
int sockets[2], flags; pid_t pid;
if (socketpair (AF_UNIX, SOCK_STREAM, 0, sockets)) { perror ("socketpair"); return -1; }
switch (pid = fork ()) {
case -1: perror ("fork"); return -1;
case 0: pause ();
default: if ((flags = fcntl (sockets[0], F_GETFL)) < 0) { perror ("fcntl, GETFL"); return -1; } if (fcntl (sockets[0], F_SETFL, flags | O_NONBLOCK | O_ASYNC) < 0) { perror ("fcntl, SETFL"); return -1; } if (fcntl (sockets[0], F_SETOWN, pid) < 0) { perror ("fcntl, SETOWN"); return -1; } }
return 0; } - To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
| |