wizard%wisdom.bitnet@WISCVM.ARPA (05/13/85)
From: Mike Trachtman <wizard%wisdom.bitnet@WISCVM.ARPA> 1) have a swapfd system call Usage: swapfd(fd1,proc,fd2) or possibly: swapfd(proc1,fd1,proc2,fd2) what this does, is makes procs (usually another process) fd2, to become my fd1, and my fd1 to become (point to a file structure) of procs fd2. thus effectively these two processes have swapped fd's I think that this should be easy to implement in the system. This could be useful for the following purposes. 1) If I need more fd's then allowed, I could make a child process who would hold those fd's I currently do not need. 2) A change to the shell, so that a job while running (or stopped) could have its ouput redirected someplace else. for example, some program generated more output then expected, then I can suspend it, then redirect the output to a file or a pipe. with % fg %1 >file or % fg %1 | filter | ... & or % fg %1 <file after some initial input is read from the terminal and the rest should be read from the file 3) a mechanism for suspended logins. when a user does a suspend to a login shell, have init when the person relogins, swapfds to the new fds of the terminal the user is at now. Obviously, the two procs should have the same owner, or the one doing it should be su. Side notes: I think that a process whose fd has been swapped should be notified (signalled) of it, so that it can resync, or change its idea of what kind of buffering need be done. this could be done automatically in the stdio library, unless the user wants to control it, then he must also inform stdio. 2) have another version of the exit sytem call, which will just cause the parents wait to return, without the process really exiting. This so that a process could put itself in background. (i.e. the shell would interpret that as a returned wait that the process does not want to be waited for anymore) What do people think?? What does Berkeley think ?? Mike (We run BSD 4.2) Mike Trachtman My address: wizard@wisdom (BITNET) wizard%wisdom.bitnet@wiscvm.ARPA (ARPA/CSNET) wizard%wisdom.bitnet@berkley (ARPA/CSNET) and if all else fails (ONLY for VERY short items) ...!decvax!humus!wisdom!wizard (UUCP) (One should not say anything, when one has nothing to say.)
tim@cithep.UucP (Tim Smith ) (05/22/85)
Re: system call to swap file table entries among processes... I have always thought that this is reasonable, and that any system with something like Berkely job control should do this. I could not think of anything wrong with it. > 3) a mechanism for suspended logins. > when a user does a suspend to a login shell, > have init when the person relogins, swapfds to the new fds of > the terminal the user is at now. I am not sure I understand. If the goal is to get something like the reattach facility of TOPS-10, then it won't work. Your old tty will still be your controlling terminal. > > 2) have another version of the exit sytem call, > which will just cause the parents wait to return, > without the process really exiting. > This so that a process could put itself in background. > (i.e. the shell would interpret that as a returned wait > that the process does not want to be waited for anymore) > How about FakeExit( value ) int value; { int pid; #ifdef PRIMITIVE_UNIX_WITHOUT_COPY_ON_WRITE_FORK # ifdef BSD # define fork vfork # endif #endif while ( ( pid = fork() ) < 0 ) ; if ( pid ) _exit( value ); } -- Tim Smith ihnp4!{wlbr!callan,cithep}!tim
henry@utzoo.UUCP (Henry Spencer) (06/17/85)
> 1) have a swapfd system call > Usage: swapfd(fd1,proc,fd2) > or possibly: swapfd(proc1,fd1,proc2,fd2) > > what this does, is makes procs (usually another process) fd2, to become > my fd1, and my fd1 to become (point to a file structure) of procs fd2. Dennis Ritchie has implemented a nicer version of this in V8: you can send file descriptors across pipes. This does require the cooperation of the other process, which is an advantage or a disadvantage depending on what you are doing. > 2) have another version of the exit sytem call, > which will just cause the parents wait to return, > without the process really exiting. > This so that a process could put itself in background. This is trivial to do in standard Unix; just have the child process fork a new child, and then exit. (Remember that a child of a dead process does not become a child of the deceased's parent, it becomes an orphan.) This has been used in things like daemons since time immemorial (i.e. 1974 or earlier!). -- Henry Spencer @ U of Toronto Zoology {allegra,ihnp4,linus,decvax}!utzoo!henry
paulsc@tekecs.UUCP (Paul Scherf) (06/21/85)
>> 1) have a swapfd system call >> Usage: swapfd(fd1,proc,fd2) >> or possibly: swapfd(proc1,fd1,proc2,fd2) >> >> what this does, is makes procs (usually another process) fd2, to become >> my fd1, and my fd1 to become (point to a file structure) of procs fd2. You might try using sockets on 4.2BSD to pass file descriptors. Paul Scherf, Tektronix, Wilsonville, Oregon, USA, tektronix!tekecs!paulsc