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 opentemp(char *template)
50 p = estrdup(template);
54 if(access(p, 0) < 0 && (fd=create(p, ORDWR|ORCLOSE, 0400)) >= 0)
59 fprint(2, "couldn't make temporary file\n");
69 * spool standard input to /tmp.
70 * we've already read the initial in bytes into ibuf.
73 spooltodisk(uchar *ibuf, int in, char **name)
79 strcpy(temp, "/tmp/pagespoolXXXXXXXXX");
82 *name = estrdup(temp);
84 if(write(fd, ibuf, in) != in){
85 fprint(2, "error writing temporary file\n");
89 while((n = read(stdinfd, buf, sizeof buf)) > 0){
90 if(write(fd, buf, n) != n){
91 fprint(2, "error writing temporary file\n");
92 wexits("write temp0");
100 * spool standard input into a pipe.
101 * we've already ready the first in bytes into ibuf
104 stdinpipe(uchar *ibuf, int in)
110 fprint(2, "pipe fails: %r\n");
114 switch(rfork(RFPROC|RFFDG)){
116 fprint(2, "fork fails: %r\n");
126 write(p[1], ibuf, in);
127 while((n = read(stdinfd, buf, sizeof buf)) > 0)
131 return -1; /* not reached */