Not entirely, no, but combining it with some plain Pike should do it:
array(Stdio.File) make_ptypair() { Stdio.File pf = Stdio.File(), tf = Stdio.File(); foreach(get_dir("/dev/"), string pty_name) if(pty_name[..2]=="pty" && pf->open("/dev/"+pty_name, "rw")) { if(tf->open("/dev/t"+pty_name[1..], "rw")) return ({ pf, tf }); pf->close(); } return 0; }
int main() { string luser = "fooson"; array(Stdio.File) f = make_ptypair(); object p = Process.create_process(({"passwd", "-r", "nis", luser }), (["setsid":f[1], "stdin":f[1], "uid":luser])); f[1]->close(); f[0]->write("hejhopp\n"); f[0]->write("hejhopp\n"); return p->wait(); }
(I haven't checked f[0] and f[1] here, so there might possibly be some confusion in the code. Please ignore that for now. :) )
And actually does on some system. I agree that is something that should be built in, but as long as I can't come up with the reason the current solution isn't working there isn't much point in making a permanent one.
/ Peter Bortas
Previous text:
2003-04-16 02:47: Subject: Pike Cookbook
setsid doesn't do what you need, you need a tty/pty pair to do that stuff. I don't think anybody would object if you implement tty/pty allocation. Hint: Originally I envisioned it being an argument to Stdio.File()->pipe().
/ Fredrik (Naranek) Hubinette (Real Build Master)