15 fprint(2, "out of memory allocating %d\n", sz);
23 erealloc(void *v, int sz)
27 fprint(2, "out of memory allocating %d\n", sz);
37 if((t = strdup(s)) == nil) {
38 fprint(2, "out of memory in strdup(%.10s)\n", s);
45 * spool standard input to /tmp.
46 * we've already read the initial in bytes into ibuf.
49 spooltodisk(uchar *ibuf, int in, char **name)
54 strcpy(tempfile, "/tmp/pagespoolXXXXXXXXX");
55 fd = opentemp(tempfile, ORDWR);
57 *name = estrdup(tempfile);
59 if(write(fd, ibuf, in) != in){
60 fprint(2, "error writing temporary file\n");
64 while((n = read(stdinfd, buf, sizeof buf)) > 0){
65 if(write(fd, buf, n) != n){
66 fprint(2, "error writing temporary file\n");
67 wexits("write temp0");
74 typedef struct StdinArg StdinArg;
83 * spool standard input into a pipe.
84 * we've already ready the first in bytes into ibuf
97 fprint(2, "pipe fails: %r\n");
101 send(arg->cp, &p[0]);
103 write(p[1], arg->ibuf, arg->in);
104 while((n = read(stdinfd, buf, sizeof buf)) > 0)
112 stdinpipe(uchar *ibuf, int in) {
118 arg.cp = chancreate(sizeof(int), 0);
119 proccreate(_stdinpipe, &arg, mainstacksize);