[MUD-Dev] Mail from mud Zoran's final Imp

JC Lawrence claw at under.Eng.Sun.COM
Tue Jan 6 16:28:03 CET 1998


On Fri, 2 Jan 1998 11:12:08 PST8PDT 
Shawn Halpenny<malachai at iname.com> wrote:

> On Thu, 1 Jan 1998 coder at ibm.net wrote:

>> A lurking and insidious problem here is that you don't detect when
>> mail delivery fails.  This can be a bitch to a) notice when it
>> happens, and b) determine the cause when it does
>> 
>> I'd suggest putting in a signal handler which triggers on the child
>> dieing, and then reports an appropriate response to the user if the
>> delivery failed.  It's fairly trivial to do: you can use any of
>> your standard IPC calls to handle reporting the failure/success
>> code (I do it with threads instead of full processes via, so I do
>> the report back via the thread object for the mailer thread).

> Isn't it easier to check the return value from system(), since the
> wait() call inside system() is already waiting for the child to
> exit?  Checking whether it exited successfully, failed because of
> something user-controllable, or died on some nasty signal is where
> the WIFxxxx macros come in handy (see /usr/include/sys/wait.h).
> Since you're using system() instead of doing the fork() and exec()
> yourself, remember that there can be a difference in the returned
> status if it was the shell that was abnormally terminated instead of
> the command process.

Bugger, I forgot the WIF* macros.

Note: You're going to need to do either a fork()/system()/exit() or a
fork()/exec()/exit(), and it really doesn't matter which except that
the latter is cheaper on page space.  Either way you need the fork
such that the main process doesn't have to wait for the child.

--
J C Lawrence                               Internet: claw at null.net
                                           Internet: coder at ibm.net
----------(*)                        Internet: jc.lawrence at sun.com
...Honourary Member of Clan McFud -- Teamer's Avenging Monolith...



More information about the mud-dev-archive mailing list