Re: Child process does not inherit parent's working library
- From: "Mr. K.V.B.L." <kenverybigliar@xxxxxxxxx>
- Date: Tue, 23 Dec 2008 09:45:10 -0800 (PST)
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(¤tLibList, 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
.
- Follow-Ups:
- Re: Child process does not inherit parent's working library
- From: dieter . bender
- Re: Child process does not inherit parent's working library
- References:
- Child process does not inherit parent's working library
- From: Mr. K.V.B.L.
- Re: Child process does not inherit parent's working library
- From: dieter . bender
- Child process does not inherit parent's working library
- Prev by Date: SSP Auto Response does not respond.
- Next by Date: Re: Child process does not inherit parent's working library
- Previous by thread: Re: Child process does not inherit parent's working library
- Next by thread: Re: Child process does not inherit parent's working library
- Index(es):
Relevant Pages
|