Re: Child process does not inherit parent's working library



On Dec 23, 3:14 am, dieter.ben...@xxxxxxxxxxx wrote:
one thing you should have in mind is, that multithreading starts an
additional BCI Job if the referred JOBD of SBMJOB has ALWMLTTHD(*NO), but
this should not change the curlib.
if your socket listener using spawn is written in rpg or uses rpg programms
or serviceprogramm, it would'nt work anyway, because rpgs multi threading
capabilities are very limited (even in V6R1 - compared to c++ or java)

Dieter Bender



Mr. K.V.B.L. wrote:
SBMJOB
    CMD(CALL PGM(KBEARD/TRANS_ENG)
    PARM('666'))
    JOB(TRANS_ENG)
    JOBQ(*LIBL/QS36EVOKE)
    CURLIB(ICCTEST01P)
    CPYENVVAR(*YES)

I have this SBMJOB command.  TRANS_ENG is program that is doing socket
communications.  It receives a message, looks at the message, and
decides which program to start based on the content.  However, the
child programs it starts do not have the current library set to the
parent's (which I have set manually via the CURLIB parameter).  They
are started in my default library instead.  TRANS_ENG uses spawnp() to
start these programs.  The documentation at

http://publib.boulder.ibm.com/iseries/v5r1/ic2924/index.htm?info/apis...



says that the child process inherits the current working *directory*
but no mention is made of the current working library.

So how can I get the child programs to start working in the library I
specify with CURLIB()?



Ok everyone, I think I am sorted out. Turns out my programs do seem
to starting off in the current library of the job that is spawn()-ing
them. I wrote a quick routine that used QWCRTVCA() to fetch the
current library and it was correct. What was throwing me off is the
CLI SQL routines I am using do not default to the current library if
you do not set a library. They use your user profile library. So I
was seeing all of these CLI routines fail because they weren't using
the program's current library but mine.


As a contribution to the group, here is a C++ routine to get the
process' current working library. If you see any problems with it,
let me know.

#include <iostream>
#include <string>
#include <cstdio>
#include <qusec.h>
#include <qwcrtvca.h>
#include <qusrjobi.h>


using namespace std;


const int IBM_Current_Library = 310;
const int IBM_Product_Libraries = 1660;
const int IBM_System_Library_List = 1980;
const int IBM_User_Library_List = 2110;
const int IBM_All_Library_Portions = 2702;


typedef struct {
Qus_EC_t ec_fields;
char Exception_Data[200];
} error_code_t;

typedef _Packed struct {
Qwc_RTVC0200_t rtvc0200;
char arrayOfLibs[1000];
} RTVC0200;



/*
Module:
GetCurLib()
Synopsis:
Get current library from the AS/400
Returns:
Nothing (void).
Written by:
Kelly Beard
Compilation:
CRTBNDCPP PGM(LIB) SRCSTMF(LIBRARY.CPP) DEFINE(TEST_MAIN)
*/
void GetCurLib(string& currentLibrary)
{
static int attribKeys[1];
static error_code_t error_code;
static first_time = true;
RTVC0200 currentLibList;
size_t found;


if (first_time) {
first_time = false;
error_code.ec_fields.Bytes_Provided = sizeof(error_code_t);
attribKeys[0] =
IBM_Current_Library;
}

QWCRTVCA(&currentLibList, sizeof(currentLibList), "RTVC0200", 1,
&attribKeys[0], &error_code);
if (error_code.ec_fields.Bytes_Available == 0)
{
currentLibrary.assign(currentLibList.arrayOfLibs, 10);
found = currentLibrary.find(' ');
if (found != string::npos) {
currentLibrary.erase(found);
}
}
}


#if defined(TEST_MAIN)
int main(int argc, char *argv[])
{
string str;

GetCurLib(str);

cout << "{" << str << "}" << endl;
}
#endif
.



Relevant Pages

  • Re: Unable to use the interval timer
    ... I need your help with a routine I'm unable to write properly. ... I want to use the Interval Timer which, unless I'm wrong, is the only ... MOV   R0,#&10 ... ADR   R1,Code_Timer ...
    (comp.sys.acorn.programmer)
  • Re: Newly getting started in C#
    ... In VB I would create the connection to the database and connect to it ... put the connection routine in the program.cs module? ... Scott Roberts    Visa profil ... namespace MyDAL ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: Move Non Zero Columns Left?
    ...   k = 1 ... just testing out the routine. ... Now go back to the Tools menu in your sheet and goto Macro then select ...  You will see the CopyNumbers macro in the list. ...
    (comp.databases.ms-access)
  • Re: inspiration
    ...    'Routine' is not 'ritual'. ... writer to professional levels, and two, you may someday get to a point ... I actively dislike routine. ... I read a lot when I'm not writing. ...
    (rec.arts.sf.composition)
  • Re: A "simple" routine used in 30-odd programs which is probably wrong!
    ... routine, all which are very very similar, but which differ in ... C    OBJECT: TO CALCULATE ... C LABEL 100 USES RESULT. ... one of the expressions is incorrect.. ...
    (comp.lang.fortran)