Re: C code to get running job name

2018-01-14 Thread Charles Mills
les -Original Message- From: IBM Mainframe Discussion List [mailto:IBM-MAIN@LISTSERV.UA.EDU] On Behalf Of Clark Morris Sent: Sunday, January 14, 2018 12:39 PM To: IBM-MAIN@LISTSERV.UA.EDU Subject: Re: C code to get running job name [Default] On 14 Jan 2018 09:18:26 -0800, in bit.listserv.

Re: C code to get running job name

2018-01-14 Thread Kirk Wolf
Uggh.no wonder people complain about C/C++ :-) Much better to use the IBM EDCDSECT utility to map the DSECTs that you want to use into C structs. We wrote a little REXX wrapper for it that I posted here once so that you can use edcdsect as a shell command in a Makefile: ihapsa.h: echo "

Re: C code to get running job name

2018-01-13 Thread John McKown
​Just for fun, I wrote the C code below. It does the "chain chasing" to get some of the information mentioned in this thread. ​ ​Given the responses on another thread, I'm basically abandoning the idea of "system level C interface" routines, such as for ENQ/DEQ et al. I might even try to get a

Re: C code to get running job name

2018-01-12 Thread Gord Tomlin
On 2018-01-12 15:37, Steve Smith wrote: Gotcha! There's a subtle difference between BUTTBJBNI and ASCBJNI. The former is defined as a 'D' (bogusly), and contains the actual jobname. The latter points to the jobname, possibly to the former, but who knows. You can't do a 1-byte test on that

Re: C code to get running job name

2018-01-12 Thread Steve Smith
Gotcha! There's a subtle difference between BUTTBJBNI and ASCBJNI. The former is defined as a 'D' (bogusly), and contains the actual jobname. The latter points to the jobname, possibly to the former, but who knows. You can't do a 1-byte test on that address, only on the character field. sas

Re: C code to get running job name

2018-01-12 Thread Ed Jaffe
On 1/12/2018 4:49 AM, Peter Relson wrote: If ASSBJBNI first byte is not x'00' then use ASSBJBNI else use ASSBJBNS This is the first I've heard of the "first byte test" trick. All of our code does this (or something very similar): |   LLGT  R14,PSAAOLD |   LLGT  R14,ASCBJBNI |   IF

Re: C code to get running job name

2018-01-12 Thread Steve Smith
It took me a while to discern the difference between ASSBJBNx and ASCBJBNx. I initially thought you were repeating yourself :-). Yet another way to skin this cat is to go from ASSBJSAB -> JSABJBNM. The JSAB also has the JOB ID (among other things, of course). sas On Fri, Jan 12, 2018 at 7:49

Re: C code to get running job name

2018-01-12 Thread Peter Relson
FWIW, If I want to get the jobname, I use ASSBJBNI (ASSBJBNS if this is a started task). If ASSBJBNI first byte is not x'00' then use ASSBJBNI else use ASSBJBNS PSAAOLD -> ASCBASSB -> ASSB. This has been available for going on 25 years. And prior to that (and you can still use this if

Re: C code to get running job name.

2018-01-11 Thread Charles Mills
-MAIN@LISTSERV.UA.EDU Subject: Re: C code to get running job name. > Why not psatold to TCB, tcbtio to TIOT, then tiocnjob? Not that I would think this is likely to occur, but if such C code happened to be run as SRB, PSATOLD would be zero. Accessing these fields via PSAAOLD will still w

Re: C code to get running job name.

2018-01-11 Thread Charles Mills
@LISTSERV.UA.EDU Subject: Re: C code to get running job name. __jobname(), __stepname() etc are not documented in the XL C/C++ Runtime Library Reference Version 2 Release 2 SC14 manual. Where are they documented? -Original Message- From: IBM Mainframe Discussion List [mailto:IBM-MAIN

AW: Re: C code to get running job name.

2018-01-11 Thread Peter Hunkeler
>Ah, you're right. It's when I execute a command from the shell that the digit is added to the end of the "jobname". I.e. the shell itself runs under "USERID", but when I do a "sleep 60s", the sleep command runs under "USERID1" (for example). Every command that the shell fork()s will run in a

Re: C code to get running job name.

2018-01-11 Thread John McKown
8:19 AM > To: IBM-MAIN@LISTSERV.UA.EDU > Subject: Re: C code to get running job name. > > John McKown wrote: > > >On Wed, Jan 10, 2018 at 11:19 AM, Thomas David Rivers <riv...@dignus.com> > >wrote: > > > > > > > >> > >

Re: C code to get running job name.

2018-01-11 Thread Barkow, Eileen
: Thursday, January 11, 2018 8:19 AM To: IBM-MAIN@LISTSERV.UA.EDU Subject: Re: C code to get running job name. John McKown wrote: >On Wed, Jan 10, 2018 at 11:19 AM, Thomas David Rivers <riv...@dignus.com> >wrote: > > > >> >>> >>> >>> >>In

Re: C code to get running job name.

2018-01-11 Thread John McKown
On Thu, Jan 11, 2018 at 1:44 AM, Peter Hunkeler wrote: > > > ​>Userids have nothing to do with job names, in general. If a user logs > into > a UNIX shell, the UNIX process runs in a new STC whose name is based on the > USERID plus 1 character (sort of "random"). I am _guessing_

Re: C code to get running job name.

2018-01-11 Thread Thomas David Rivers
John McKown wrote: On Wed, Jan 10, 2018 at 11:19 AM, Thomas David Rivers wrote: In Systems/C , this is simply: #include #include main() { printf("Job name is %s\n", __jobname()); } That is a nice enhancement for the C language under

AW: Re: C code to get running job name.

2018-01-11 Thread Peter Hunkeler
>The problem is when a program is started from OMVS under a USERID and runs >under a different name, which makes it difficult for someone to cancel the job >or issue modify commands against it. >The system keeps appending numerical values to the USERID and you have to do a >DA userid* command

AW: Re: C code to get running job name.

2018-01-10 Thread Peter Hunkeler
​>Userids have nothing to do with job names, in general. If a user logs into a UNIX shell, the UNIX process runs in a new STC whose name is based on the USERID plus 1 character (sort of "random"). I am _guessing_ that with an 8 character RACF id, the UNIX process runs in an STC with the 8

AW: Re: C code to get running job name.

2018-01-10 Thread Peter Hunkeler
>>How does cancelling the parent job affect its children? Might they continue >>running? >The same way it works on any unix: Child processed are terminated when the >parent terminates. The above statement is wrong. I mixed this up with special shell behaviour. The shell terminates its

Re: C code to get running job name.

2018-01-10 Thread John McKown
On Wed, Jan 10, 2018 at 3:24 PM, Paul Gilmartin < 000433f07816-dmarc-requ...@listserv.ua.edu> wrote: > On Wed, 10 Jan 2018 21:05:15 +, Barkow, Eileen wrote: > > >Thanks again John. I will try it out. > > > >The problem is when a program is started from OMVS under a USERID and > runs under

Re: C code to get running job name.

2018-01-10 Thread Paul Gilmartin
On Wed, 10 Jan 2018 21:05:15 +, Barkow, Eileen wrote: >Thanks again John. I will try it out. > >The problem is when a program is started from OMVS under a USERID and runs >under a different name, which makes it >difficult for someone to cancel the job or issue modify commands against it.

Re: C code to get running job name.

2018-01-10 Thread Barkow, Eileen
@LISTSERV.UA.EDU Subject: C code to get running job name. Sorry, but I deleted the email which had the original question. Just for "fun" (but no profit), I wrote the following C code to display the name of the job under which the program is running. It can be improved a bit, but it shows

Re: C code to get running job name.

2018-01-10 Thread John McKown
On Wed, Jan 10, 2018 at 11:42 AM, Paul Gilmartin < 000433f07816-dmarc-requ...@listserv.ua.edu> wrote: > On Wed, 10 Jan 2018 11:26:39 -0600, John McKown wrote: > > >On Wed, Jan 10, 2018 at 11:19 AM, Thomas David Rivers wrote: > > > >> printf("Job name is %s\n", __jobname()); > >> > >That

Re: C code to get running job name.

2018-01-10 Thread Paul Gilmartin
On Wed, 10 Jan 2018 11:26:39 -0600, John McKown wrote: >On Wed, Jan 10, 2018 at 11:19 AM, Thomas David Rivers wrote: > >> printf("Job name is %s\n", __jobname()); >> >That is a nice enhancement for the C language under z/OS. As a general >rule, I _try_ to avoid any functions ... Another nice

Re: C code to get running job name.

2018-01-10 Thread John McKown
On Wed, Jan 10, 2018 at 11:19 AM, Thomas David Rivers wrote: > John McKown wrote: > > Sorry, but I deleted the email which had the original question. Just for >> "fun" (but no profit), I wrote the following C code to display the name of >> the job under which the program is

Re: C code to get running job name.

2018-01-10 Thread Thomas David Rivers
John McKown wrote: Sorry, but I deleted the email which had the original question. Just for "fun" (but no profit), I wrote the following C code to display the name of the job under which the program is running. It can be improved a bit, but it shows the basics. #include #include ... In

Re: C code to get running job name.

2018-01-10 Thread John McKown
] On > Behalf Of John McKown > Sent: Wednesday, January 10, 2018 5:58 AM > To: IBM-MAIN@LISTSERV.UA.EDU > Subject: C code to get running job name. > > Sorry, but I deleted the email which had the original question. Just for > "fun" (but no profit), I wrote the followi

Re: C code to get running job name.

2018-01-10 Thread Charles Mills
Of John McKown Sent: Wednesday, January 10, 2018 5:58 AM To: IBM-MAIN@LISTSERV.UA.EDU Subject: C code to get running job name. Sorry, but I deleted the email which had the original question. Just for "fun" (but no profit), I wrote the following C code to display the name of the job u

C code to get running job name.

2018-01-10 Thread John McKown
Sorry, but I deleted the email which had the original question. Just for "fun" (but no profit), I wrote the following C code to display the name of the job under which the program is running. It can be improved a bit, but it shows the basics. #include #include #include int main(int argc, char