1 #include "wvsendmail.h"
3 int WvSendmailProc::num_sendmails
= 0;
5 WvSendmailProc::WvSendmailProc(const char **argv
, int _count
,
6 const WvSendmailCallback
&_cb
)
7 : WvPipe(argv
[0], argv
, true, false, false), count(_count
), cb(_cb
)
9 is_done
= exited
= false;
14 WvSendmailProc::~WvSendmailProc()
20 // be certain the callback gets called
22 cb(count
, (ret
== 0));
28 bool WvSendmailProc::pre_select(SelectInfo
&si
)
32 if (is_done
&& !exited
&& si
.msec_timeout
> 20)
35 if (child_exited() && !exited
&& is_done
)
41 cb(count
, !exit_status());
47 // another hack because isok() returns true when it shouldn't really
48 if ((exited
|| is_done
) && si
.wants
.writable
)
51 return must
|| WvPipe::pre_select(si
);
55 bool WvSendmailProc::isok() const
57 // note: this means people will try to write to us even if the pipe
59 return WvPipe::isok() || !exited
;
63 size_t WvSendmailProc::uwrite(const void *buf
, size_t count
)
66 return count
; // fake it, because isok() is also faking it
67 return WvPipe::uwrite(buf
, count
);
71 void WvSendmailProc::execute()
75 if (is_done
&& select(0, false, true, false))
80 void WvSendmailProc::done()
83 force_select(false, true);