3 do_spair(stab1, stab2, arglast)
8 register STR **st = stack->ary_array;
9 register int sp = arglast[2];
12 int domain, type, protocol, fd[2];
17 stio1 = stab_io(stab1);
18 stio2 = stab_io(stab2);
20 stio1 = stab_io(stab1) = stio_new();
22 do_close(stab1,FALSE);
24 stio2 = stab_io(stab2) = stio_new();
26 do_close(stab2,FALSE);
28 domain = (int)str_gnum(st[++sp]);
29 type = (int)str_gnum(st[++sp]);
30 protocol = (int)str_gnum(st[++sp]);
31 TAINT_PROPER("in socketpair");
33 if (socketpair(domain,type,protocol,fd) < 0)
36 fatal("Socketpair unimplemented");
38 stio1->ifp = fdopen(fd[0], "r");
39 stio1->ofp = fdopen(fd[0], "w");
41 stio2->ifp = fdopen(fd[1], "r");
42 stio2->ofp = fdopen(fd[1], "w");
44 if (!stio1->ifp || !stio1->ofp || !stio2->ifp || !stio2->ofp) {
45 if (stio1->ifp) fclose(stio1->ifp);
46 if (stio1->ofp) fclose(stio1->ofp);
47 if (!stio1->ifp && !stio1->ofp) close(fd[0]);
48 if (stio2->ifp) fclose(stio2->ifp);
49 if (stio2->ofp) fclose(stio2->ofp);
50 if (!stio2->ifp && !stio2->ofp) close(fd[1]);