At 8:50 PM -0500 6/9/02, Forrest Cahoon wrote:
>
>I'm working on a module that wants to know whether it's being run
>interactively, so I'm checking JPI$_MODE in a call to sys$getjpiw().
>
>Here's a test file: I think it's short enough to post:
>
>==============(beginning of jpitest.xs)=====================
First off, why write your own when you can use VMS::Process?
Secondly, VMS::Process handles JPI$_MODE just fine, so it's clearly
possible from XS:
$ perl -"MVMS::Process" -e "print VMS::Process::get_one_proc_info_item(0,'MODE');"
INTERACTIVE
>void
>test1()
>
> PREINIT:
> quadword iosb;
> ile3 itmlst[2];
> long mode;
> int status;
>
> CODE:
> itmlst[0].ile3$w_code = JPI$_MODE;
> itmlst[0].ile3$w_length = sizeof(mode);
> itmlst[0].ile3$ps_bufaddr = &mode;
> itmlst[0].ile3$ps_retlen_addr = 0;
Is specifying a place to store bytes transferred really optional? In
any case it doesn't cost much to create another unsigned short and
point to that; that way you can check and see if you really got a
4-byte answer in mode or no answer at all.
> memset(&itmlst[1], 0, sizeof(ile3));
>
> status = sys$getjpiw(0, 0, 0, itmlst, &iosb, 0, 0);
> printf ("status = %%X%08X mode = %d\n", status, mode);
You definitely need to check iosb.lo even if status is successful.
And, as I said above, it would be helpful to know whether you're
really getting something written to mode, or if mode just happens to
be zero before and after the call.
>With a test.pl that just calls jpitest::test1(), I get this output:
>
>status = %X00000001 mode = 0
>
>But 0 is JPI$K_OTHER, what I should really be getting is 3, which is
>JPI$K_INTERACTIVE. Changing this XS code into plain C, where test1()
>becomes main() and running it gives me the results I expect:
>
>status = %X00000001 mode = 3
>
>This is with Perl 5.6.0 on OpenVMS Alpha V7.3.
Any reason not to use 5.6.1?
>What the heck's going on here?
I would look at the C generated from the XS, compile it in debug and
step through it, and check the things I've mentioned above. I'm no
XS guru and there might well be some gotcha that's tripping you up,
but there's a bit more you can do to see what's happening.
--
________________________________________
Craig A. Berry
mailto:[EMAIL PROTECTED]
"... getting out of a sonnet is much more
difficult than getting in."
Brad Leithauser