From owner-freebsd-hackers Sun May 10 21:00:28 1998 Return-Path: Received: (from majordom@localhost) by hub.freebsd.org (8.8.8/8.8.8) id VAA03403 for freebsd-hackers-outgoing; Sun, 10 May 1998 21:00:28 -0700 (PDT) (envelope-from owner-freebsd-hackers@FreeBSD.ORG) Received: from awfulhak.org (awfulhak.demon.co.uk [158.152.17.1]) by hub.freebsd.org (8.8.8/8.8.8) with ESMTP id VAA03394 for ; Sun, 10 May 1998 21:00:22 -0700 (PDT) (envelope-from brian@Awfulhak.org) Received: from gate.lan.awfulhak.org (localhost [127.0.0.1]) by awfulhak.org (8.8.8/8.8.8) with ESMTP id EAA28416 for ; Mon, 11 May 1998 04:23:36 +0100 (BST) (envelope-from brian@gate.lan.awfulhak.org) Message-Id: <199805110323.EAA28416@awfulhak.org> X-Mailer: exmh version 2.0.1 12/23/97 To: freebsd-hackers@FreeBSD.ORG Subject: SCM_RIGHTS & session ids Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Date: Mon, 11 May 1998 04:23:36 +0100 From: Brian Somers Sender: owner-freebsd-hackers@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.ORG Hi, I've bumped into a bit of a problem implementing multilink ppp. Maybe someone can suggest a way out of my dilemma.... I have two processes, each of which has its own session id and is the only process in the sessions only process group. I've closed STDOUT and STDERR, and STDIN_FILENO is the only thing keeping the controlling terminal attached. Both the process group and the session id of each process is owned by its respective terminal. .-------------. .-------------. | Session 123 | | Session 456 | `-------------' `-------------' | | .------------. .------------. | /dev/cuaa0 | | /dev/cuaa1 | `------------' `------------' | | .-------------. .-------------. | Process 123 | | Process 456 | `-------------' `-------------' I wish to pass descriptor 0 from p123 to p456 using SCM_RIGHTS over a unix domain socket, and then for p123 to exit. When I do this, as soon as p456 selects on the passed descriptor (say descriptor 10), and *after* p123 has exited, I get an exception from select() (exception fdset) and the descriptor is useless. If I have p123 close() STDIN_FILENO after the transfer, then execl("/bin/sleep", "sleep", 100", NULL) p456 can read descriptor 10 for 100 seconds - once (I assume) the process group of /dev/cuaa0 is gone, all descriptors are invalidated. What I've tried (nothing's helped): o p123 does an fd = open(ttyname(STDIN_FILENO), O_RDWR), then close(STDIN_FILENO) and pass fd to p456. o p123 calls tcsetpgrp(STDIN_FILENO, 456) - doesn't work 'cos p456 isn't part of p123s session. This all works when there are no controlling terminals involved (ppp over tcp). I guess that the problem is that a process group has only one session and a session has only one controlling terminal... Is the only way to simply exec() a keepalive process() (yeuch) ? TIA. -- Brian , , Don't _EVER_ lose your sense of humour.... To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-hackers" in the body of the message