Hi Brian,
I guess the post went through after all. I couldn’t see it on the list of open threads
Here’s a snippet:
int master;
pid_t pid = forkpty(&master,0,0,0);
if (pid > 0) {
int stat = 0;
waitpid(pid,&stat,0);
return stat != 0;
}
MimeRunner rr(&r);
if (c.login(config->machine, config->user, config->password, config->account, config->account_password)) {
c.run(rr);
c.logout();
exit(r.send(200,"OK",getContentType(),rr.c_str(),rr.size()));
} else {
exit(r.send(500,"SERVER ERROR","text/html","",13));
}
and the login method in the c object (which I have as class called Runtime) is:
int Runtime::login(const char* machine, const char* user, const char* psw, const char* acct, const char* apsw)
{
CPSTR* m = _CP_mkstr((char*)machine);
CPSTR* u = _CP_mkstr((char*)user);
CPSTR* p = psw[0] ? _CP_mkstr((char*)psw) : _CP_str_null;
CPSTR* a = _CP_mkstr((char*)acct);
CPSTR* w = apsw[0] ? _CP_mkstr((char*)apsw) : _CP_str_null;
int n = _CP_logon(m,u,p,a,w,-1,0);
_CP_str_free(m);
_CP_str_free(u);
_CP_str_free(a);
if (psw[0]) _CP_str_free(p);
if (apsw[0]) _CP_str_free(w);
return n>-1;
}
When I run it, _CP_logon never returns, but instead the child dies. I’ve run it with gdb and from the stack trace it shows it dies in strcpy() called from pick_init_termio(). The session does not need to be user interactive. I’m trying to use it as a database connection with basic calling and access to standard D3 functions via the _CP_ api. The program is owned by root with the +s option set.
Any advice would be most appreciated.
Tom
> On Jan 25, 2022, at 10:58 AM, Brian Cram via Rocket Forum <
mail@forum.rocketsoftware.com> wrote:
>
> Invite your colleagues to join the Rocket Forum and grow our expert network.
> <https: community.rocketsoftware.com/="">
> D3 and mvBase <https: community.rocketsoftware.com/forums/forum-home/digestviewer?tab="digestviewer&CommunityKey=7cdcd1ff-6009-4df2-8b8c-e5ea4293200b">
> Post New Message Online <http: community.rocketsoftware.com/participate/postmessage?groupid="55">
> Invite your colleagues to join the Rocket Forum and grow our expert network. Share this link. <https: community.rocketsoftware.com/register="">
> Re: forking _CP_logon <https: community.rocketsoftware.com/forums/forum-home/digestviewer/viewthread?messagekey="4e2ed5fe-098a-45ae-8ec7-0433c806beba&CommunityKey=7cdcd1ff-6009-4df2-8b8c-e5ea4293200b&tab=digestviewer&bm=4e2ed5fe-098a-45ae-8ec7-0433c806beba">
> Reply to Group Online <https: community.rocketsoftware.com/forums/all-discussions/postreply?messagekey="4e2ed5fe-098a-45ae-8ec7-0433c806beba&ListKey=365735ee-5669-4857-ac99-8f7ea2cb2c9d"> Reply to Group <mailto:
rocket_d3andmvbase_4e2ed5fe-098a-45ae-8ec7-0433c806beba@connectedcommunity.org?subject=re:%20forking%20_cp_logon>
> <https: community.rocketsoftware.com/network/members/profile?userkey="12bb05f9-486d-4acf-93d3-6ac050875652">
> Jan 25, 2022 1:56 PM
> Brian Cram <https: community.rocketsoftware.com/network/members/profile?userkey="12bb05f9-486d-4acf-93d3-6ac050875652">
> Got small example code? I can then ask somebody.
>
> ------------------------------
> Brian S. Cram
> Principal Technical Support Engineer
> Rocket Software
> ------------------------------
> Reply to Group Online <https: community.rocketsoftware.com/forums/all-discussions/postreply?messagekey="4e2ed5fe-098a-45ae-8ec7-0433c806beba&ListKey=365735ee-5669-4857-ac99-8f7ea2cb2c9d"> View Thread <https: community.rocketsoftware.com/forums/forum-home/digestviewer/viewthread?messagekey="4e2ed5fe-098a-45ae-8ec7-0433c806beba&CommunityKey=7cdcd1ff-6009-4df2-8b8c-e5ea4293200b&tab=digestviewer&bm=4e2ed5fe-098a-45ae-8ec7-0433c806beba"> Recommend <https: community.rocketsoftware.com/forums/forum-home/digestviewer/viewthread?messagekey="4e2ed5fe-098a-45ae-8ec7-0433c806beba&CommunityKey=7cdcd1ff-6009-4df2-8b8c-e5ea4293200b&tab=digestviewer&bm=4e2ed5fe-098a-45ae-8ec7-0433c806beba&cmd=rate&cmdarg=add"> Forward <https: community.rocketsoftware.com/forums/all-discussions/forwardmessages?messagekey="4e2ed5fe-098a-45ae-8ec7-0433c806beba&ListKey=365735ee-5669-4857-ac99-8f7ea2cb2c9d"> Flag as Inappropriate <https: community.rocketsoftware.com/forums/forum-home/digestviewer/viewthread?messagekey="4e2ed5fe-098a-45ae-8ec7-0433c806beba&CommunityKey=7cdcd1ff-6009-4df2-8b8c-e5ea4293200b&tab=digestviewer&bm=4e2ed5fe-098a-45ae-8ec7-0433c806beba&MarkAppropriate=4e2ed5fe-098a-45ae-8ec7-0433c806beba"> Post New Message Online <http: community.rocketsoftware.com/participate/postmessage?groupid="55">
> -------------------------------------------
> Original Message:
> Sent: 01-25-2022 13:00
> From: Tom Marracci
> Subject: forking _CP_logon
>
> Hopefully this is the right forum for this question. Has anyone used fork (or forkpty) and successfully called _CP_logon from inside of a C program? Is there a trick to making this work? When I try it, the child dies with a segfault somewhere in pick_init_termio in a call to strcpy.
>
> ------------------------------
> Tom Marracci
> General Manager
> Aircraft Spruce
> corona CA US
> ------------------------------
>
>
>
>
> You are receiving this message because you followed the 'forking _CP_logon' message thread. To unsubscribe from this message thread, go to Unsubscribe <https: community.rocketsoftware.com/higherlogic/common/unfollow.aspx?userkey="be3cdfc2-ad06-43d5-8ba7-699e69103658&sKey=KeyRemoved&ItemKey=7b81e67f-d20f-434e-98eb-59400620e1a9">.
> Update your email preferences <https: community.rocketsoftware.com/go.aspx?c="Preferences§ion=email"> to choose the types of email you receive
>
> Unsubscribe from all participation emails <https: community.rocketsoftware.com/higherlogic/egroups/unsubscribe.aspx?userkey="be3cdfc2-ad06-43d5-8ba7-699e69103658&sKey=KeyRemoved&mClass=Social">
Original Message:
Sent: 1/25/2022 1:56:00 PM
From: Brian Cram
Subject: RE: forking _CP_logon
Got small example code? I can then ask somebody.
------------------------------
Brian S. Cram
Principal Technical Support Engineer
Rocket Software
------------------------------
Original Message:
Sent: 01-25-2022 13:00
From: Tom Marracci
Subject: forking _CP_logon
Hopefully this is the right forum for this question. Has anyone used fork (or forkpty) and successfully called _CP_logon from inside of a C program? Is there a trick to making this work? When I try it, the child dies with a segfault somewhere in pick_init_termio in a call to strcpy.
------------------------------
Tom Marracci
General Manager
Aircraft Spruce
corona CA US
------------------------------
</https:></https:></https:></http:></https:></https:></https:></https:></https:></https:></https:></mailto:rocket_d3andmvbase_4e2ed5fe-098a-45ae-8ec7-0433c806beba@connectedcommunity.org?subject=re:%20forking%20_cp_logon></https:></https:></https:></http:></https:></https:></mail@forum.rocketsoftware.com>