| Actually, this turns out to be pretty easy (easier than I thought when we
talked on the phone... the definition was just hidden in a macro). The names
have changed, but that's all. The changes are mostly because, with support
for the formal POSIX standard, we had to be much more careful about
"namespace pollution"... we're not allowed to define names like TRY, CATCH,
ENDTRY, or exc_* names when you include <pthread.h> unless you do something
"non-standard". (Including <cma.h> or <pthread_d4.h> is always
"non-standard", so they define the old names for compatibility.)
#include <pthread.h>
#include <pthread_exception.h>
.
.
.
PTHREAD_TRY_NP {
.
.
.
}
PTHREAD_CATCH_NP (pthread_exc_SIGPIPE_e) {
.
.
.
}
PTHREAD_ENDTRY_NP
And, a reminder... POSIX doesn't have exceptions, so if you use our exception
package, you are not using the "POSIX standard", and your code won't be
portable to other implementations of POSIX threads. To be completely
portable, you need to give up the power, modularity, and flexibility of
exceptions and simply set up a signal action for SIGPIPE. (Of course, doing
so will overwrite the DECthreads signal handler, and prevent any other code
in the process from catching SIGPIPE as an exception...)
/dave
|
| (By the way, I deleted your second note, 1483, on this topic. We didn't
really need two, and I think the wording of your first attempt is a little
better.)
|
| > The code has the following form TRY
> {
> sent = send(conn_id, send_bufr, send_len, 0);
> }
> CATCH (exc_SIGPIPE_e)
> {
> sigpipe = 1;
> }
> ENDTRY
Personally I prefer what Dave hinted at, simply do a:
signal(SIGPIPE, SIG_IGN);
at the appropropriate place in your startup code and
then you can code like this:
sent = send(conn_id, send_bufr, send_len, 0);
if( sent == -1 && errno == EPIPE )
sigpipe = 1; /* or whatever */
which is relatively portable to most UNIXes.
|