On 28/04/2008, at 6:31 PM, Jevgeni Astanovski wrote:

When program is called, it first generates a list of records (reply) and then starts sending them back to the caller one by one. It is a predefined logic, works fine.
Now one of our programs of this sort has a bug, that we are searching for a couple of weeks but with no success. As a result the program crashes and the file QTEMP/TEMPFILE left open.

When program is called next time, the file opening command with clearing file content (option "wr") fails because the file is being held by someone. This someone is probably the crashed previous instance....
So from that moment the program works, in the sense that it consumes resources, but does not do what is intended.
Is there something, that can be done inside our program to take care of this situation? Close the file somehow if it was left open or something alike?
I am (of course) not losing the hope to find the original bug, but have no idea how to proceed.

Advise will be highly appreciated :-)

You can try a number of different approaches:

#pragma exception_handler to catch the exception and deal with it

atexit() to register a normal completion function to close files

atiexit() MI built-in to register an abnormal completion function to close files

Change to run in a new activation group and use CEE4RAGE or CEE4RAGE2 to register an Activation Group Exit procedure to close files.

Change to run in a named activation group and use CEE4RAGE or CEE4RAGE2 to register an Activation Group Exit procedure to close files, and ensure you code kills its own activation group on error (CEETREC or CEE4ABN), or that the caller kills the activation group (RCLACTGRP) on error.

Regards,
Simon Coulter.
--------------------------------------------------------------------
FlyByNight Software OS/400, i5/OS Technical Specialists

http://www.flybynight.com.au/
Phone: +61 2 6657 8251 Mobile: +61 0411 091 400 /"\
Fax: +61 2 6657 8251 \ /
X
ASCII Ribbon campaign against HTML E-Mail / \
--------------------------------------------------------------------




As an Amazon Associate we earn from qualifying purchases.

This thread ...

Follow-Ups:
Replies:

Follow On AppleNews
Return to Archive home page | Return to MIDRANGE.COM home page

This mailing list archive is Copyright 1997-2021 by midrange.com and David Gibbs as a compilation work. Use of the archive is restricted to research of a business or technical nature. Any other uses are prohibited. Full details are available on our policy page. If you have questions about this, please contact [javascript protected email address].

Operating expenses for this site are earned using the Amazon Associate program and Google Adsense.