Peter, this bit of the system's Java documentation:
http://publib.boulder.ibm.com/infocenter/iseries/v5r4/topic/rzaha/invapiex.htm
mentions that three file descriptors should be opened in the job for
Java I/O to work when the JVM is started by the invocation API (which is
how RPG starts the JVM).  It shows some sample C code that opens the
three descriptors.
I'm struggling to understand when/where this should be used.  Are you 
suggesting that RPG should always close descriptors 0-2 and open them as 
/dev/null whenever it uses Java?
How does this interact with QIBM_USE_DESCRIPTOR_STDIO?  Or C programs? or 
QShell scripts? Will it cause havoc for them, or is it only affecting 
stdin/stdout/stderr for the RPG program?

An RPG version of this code is below; you may notice that the C version allocates to /dev/null1, null2 and null3. Apparently that is not correct; it should be /dev/null as the RPG version does.
Correct.  /dev/null is a special file (of type *CHRSF) that simply 
discards any data sent to it.  The idea is that an existing program can 
work with these streams as normal without knowing that the input/output is 
being discarded.

It is not really necessary (and maybe not advisable, I'm not sure) to
close the file descriptors since they will be closed when the job ends,
but the program can be called with parameter 'N' if you want to close
the files after the Java has completed.
See, what's part of what I'm confused about.  If I close these descriptors 
and re-open them with /dev/null, what happens when I subsequently call a C 
program?  Will it's input/output (assuming it's using stdin/stdout/stderr) 
go to/from /dev/null?  Won't that break things?
If I close them later, won't that cause an earlier C program in my call 
stack to fail when control gets back to it?   What about subsequently 
called programs?
I suppose I should test this for myself (and see what happens) rather than 
asking you.
If you assume that the RPG program is the only program that's run in the 
job, or you don't call anything else that works with descriptors 0-2, then 
I guess you'd have no problems.  I'm just a little leery of doing this 
unconditionally...





As an Amazon Associate we earn from qualifying purchases.

This thread ...

Follow-Ups:

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

This mailing list archive is Copyright 1997-2025 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 copyright@midrange.com.

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