44 while ((
pid = wait_nohang(&
wstat)) > 0)
60 if (w != -1)
return w;
61 if (errno == EINTR)
return -1;
82 buffer_put(&
bo,&ch,1);
84 buffer_putflush(&
bo,
"",1);
96 if (
flagabort) {
err(
"Zqmail-spawn: Out of memory. (#4.3.0)\n");
return; }
97 if (
delnum < 0) {
err(
"Zqmail-spawn: Internal error: delnum negative. (#4.3.5)\n");
return; }
98 if (
delnum >=
auto_spawn) {
err(
"Zqmail-spawn: Internal error: delnum too big. (#4.3.5)\n");
return; }
99 if (
d[
delnum].used) {
err(
"Zqmail-spawn: Internal error: delnum in use. (#4.3.5)\n");
return; }
101 for (i = 0; i <
messid.len; ++i)
103 if (!i || (
messid.s[i] !=
'/'))
104 if ((
unsigned char) (
messid.s[i] -
'0') > 9)
105 {
err(
"Dqmail-spawn: Internal error: messid has nonnumerics. (#5.3.5)\n");
return; }
107 if (
messid.len > 100) {
err(
"Dqmail-spawn: Internal error: messid too long. (#5.3.5)\n");
return; }
108 if (!
messid.s[0]) {
err(
"Dqmail-spawn: Internal error: messid too short. (#5.3.5)\n");
return; }
111 {
err(
"Zqmail-spawn: Out of memory. (#4.3.0)\n");
return; }
114 if (
j >=
recip.len) {
err(
"DSorry, address must include host name. (#5.1.3)\n");
return; }
116 fdmess = open_read(
messid.s);
117 if (fdmess == -1) {
err(
"Zqmail-spawn: Unable to open message. (#4.3.0)\n");
return; }
119 if (fstat(fdmess,&st) == -1)
120 { close(fdmess);
err(
"Zqmail-spawn: Unable to fstat message. (#4.3.0)\n");
return; }
121 if ((st.st_mode & S_IFMT) != S_IFREG)
122 { close(fdmess);
err(
"ZSorry, message has wrong type. (#4.3.5)\n");
return; }
125 { close(fdmess);
err(
"ZSorry, message has wrong owner. (#4.3.5)\n");
return; }
127 if (pipe(pi) == -1) {
128 if (errno == EFAULT)
err(
"Zqmail-spawn: Unable to create pipe (wrong fildes). (#4.3.0)\n");
129 else if (errno == EMFILE)
err(
"Zqmail-spawn: Unable to create pipe (too many FDS). (#4.3.0)\n");
130 else if (errno == ENFILE)
err(
"Zqmail-spawn: Unable to create pipe (system file table full). (#4.3.0)\n");
131 else if (errno == ENOMEM)
err(
"Zqmail-spawn: Unable to create pipe (out of memory). (#4.3.0)\n");
132 else err(
"Zqmail-spawn: Unable to create pipe (unkown reason). (#4.3.0)\n");
143 { close(pi[0]); close(pi[1]);
err(
"Zqmail-spawn: Unable to fork. (#4.3.0)\n");
return; }
168 for (i = 0; i < r; ++i) {
172 delnum = (
unsigned int) (
unsigned char) ch;
202 if (chdir(
"queue/mess") == -1)
_exit(110);
218 buffer_putflush(&
bo,&ch,1);
236 FD_SET(
d[i].
fdin,&rfds);
237 if (
d[i].
fdin >= nfds)
238 nfds =
d[i].
fdin + 1;
241 r = select(nfds,&rfds,(fd_set *) 0,(fd_set *) 0,(
struct timeval *) 0);
246 if (FD_ISSET(0,&rfds))
getcmd();
250 if (FD_ISSET(
d[i].
fdin,&rfds)) {
256 buffer_put(&
bo,&ch,1);
258 buffer_put(&
bo,
"",1);
263 while (!stralloc_readyplus(&
d[i].
output,r))
269 char *truncmess =
"\nError report too long, sorry.\n";
271 stralloc_cats(&
d[i].
output,truncmess);
int stralloc_copys(stralloc *, char const *)
ssize_t okwrite(int fd, char *buf, int n)