maart@cs.vu.nl (Maarten Litmaath) (05/03/88)
Right now it's impossible to redirect output while a program is running, by typing something like: % a.out [bla bla gnome hobgoblin... invisible stalker... Mount device busy] ^Z % bg > /etc/passwd % (To catch some signal from inside the program, etc. is not a general solution!) There should be some system call to indicate that some stream of a child is to be reopened. The indication will probably be some kind of signal. The C interface could be something like: int redirect(pid, fd, file) int pid, fd; char *file; to connect file descriptor fd to file, and int dup3(pid, fd, newfd) int pid, fd, newfd; to make file descriptor fd a duplicate of newfd. In my opinion the UNIX kernel data structures are suited for these ideas. Am I blundering about, forgetting something important, or why haven't they been implemented yet? -- South-Africa: |Maarten Litmaath @ Free U Amsterdam: revival of the Third Reich |maart@cs.vu.nl, mcvax!botter!ark!maart
mike@turing.UNM.EDU (Michael I. Bushnell) (05/05/88)
In article <1242@ark.cs.vu.nl> maart@cs.vu.nl (Maarten Litmaath) writes: >There should be some system call to indicate that some stream of a child >is to be reopened. The indication will probably be some kind of signal. >The C interface could be something like: > > int redirect(pid, fd, file) > int pid, fd; > char *file; > >to connect file descriptor fd to file, and > > int dup3(pid, fd, newfd) > int pid, fd, newfd; > >to make file descriptor fd a duplicate of newfd. >In my opinion the UNIX kernel data structures are suited for these ideas. >Am I blundering about, forgetting something important, or why haven't >they been implemented yet? Sigh. This is real hard to do for the same reason fixing vhangup is hard. The file descriptors are in the processes u. area, and are thus unavailable to the parent when it executes the system call. Signal delivery faces the same problem, and is solved by a hack in the swapin code. N u m q u a m G l o r i a D e o Michael I. Bushnell HASA - "A" division 14308 Skyline Rd NE Computer Science Dept. Albuquerque, NM 87123 OR Farris Engineering Ctr. OR University of New Mexico mike@turing.unm.edu Albuquerque, NM 87131 {ucbvax,gatech}!unmvax!turing.unm.edu!mike
maart@cs.vu.nl (Maarten Litmaath) (05/18/88)
In article <1028@unmvax.unm.edu> mike@turing.UNM.EDU.UUCP (Michael I. Bushnell) writes: \In article <1242@ark.cs.vu.nl> maart@cs.vu.nl (Maarten Litmaath) writes: \ \>There should be some system call to indicate that some stream of a child \>is to be reopened. The indication will probably be some kind of signal. \>... \ \Sigh. This is real hard to do for the same reason fixing vhangup is \hard. The file descriptors are in the processes u. area, and are thus \unavailable to the parent when it executes the system call. What's wrong with the following: supply the process id, and the kernel can come up with anything you want to know about the process, including signal indication bits, file descriptors, etc., so you can change them too. -- South-Africa: |Maarten Litmaath @ Free U Amsterdam: revival of the Third Reich |maart@cs.vu.nl, mcvax!botter!ark!maart