Something like assert() while define NDEBUG, but not abort()

A

Alex Vinokur

Hi,

From man abort() on HP-UX

-------------------------------
abort() first closes all open files, streams, directory streams, and
message catalogue descriptors,
------------------------------

1. Does assert() have the same behavior?

2. If assert() doesn't close all open files, streams, directory
streams etc,
is there any possibility to cause assert()-like behavior in case
that NDEBUG defined?


Alex Vinokur
 
G

Guest

From man abort() on HP-UX

assert() calls abort() (I checked the standard)

2. If assert() doesn't close all open files, streams, directory
streams etc,
    is there  any possibility to cause assert()-like behavior in case
that  NDEBUG defined?

mu
 
E

Eric Sosman

Alex said:
Hi,

From man abort() on HP-UX

This is (presumably) true of the abort() on HP-UX, but
is not necessarily true of all abort() implementations on
all systems. 7.20.4.1p2: "[...] Whether open streams with
unwritten buffered data are flushed, open streams are closed,
or temporary files are removed is implementation-defined. [...]"
1. Does assert() have the same behavior?

See Nick Keighley's response.
2. If assert() doesn't close all open files, streams, directory
streams etc,
is there any possibility to cause assert()-like behavior in case
that NDEBUG defined?

Since assert() calls abort() and abort() calls (or does
the equivalent of) raise(SIGABRT), you could try installing a
handler for SIGABRT and do your cleanup in the signal handler.
But on a system where abort() doesn't clean up anyhow there's
likely to be a good reason, and that reason (whatever it is)
may also get in the way of your signal handler's efforts.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,756
Messages
2,569,540
Members
45,025
Latest member
KetoRushACVFitness

Latest Threads

Top