cancel
Showing results for 
Search instead for 
Did you mean: 

pclose hanging

 
UnixTeam (Enbridge)
Occasional Contributor

pclose hanging

We have a C++ program that's been in use for over 10 years. Sometime in the last couple of years it started hanging on a call to pclose - the process just stalls and doesn't return.

Since it's being used to open an ssh connection to a remote host, I suspect it might be caused by some form of network instability. There are multiple copies of this process running constantly on multiple hosts and the problem occurs quite rarely.

The code looks like this:

_popenFile = popen("ssh -q -o 'StrictHostKeyChecking no' -o 'AllowedAuthentications publickey' someRemoteHost someRemoteProcess", "r");
if (_popenFile == (FILE *)NULL)

if ((_filDes = fileno (_popenFile)) == -1)

_popenIfStream.attach (_filDes);
if (!_popenIfStream)




_popenIfStream.detach ();
pclose (_popenFile);
5 REPLIES 5
skt_skt
Honored Contributor

Re: pclose hanging

is the popen failing only when ssh is involved? what is the ssh version and OS version? Did u try putting remsh instead?
UnixTeam (Enbridge)
Occasional Contributor

Re: pclose hanging

Santhosh wrote:

> is the popen failing only when ssh is involved?

If any other calls to popen are failing I'm unaware of it.

> what is the ssh version and OS version?

ssh2 3.2.0 and HP-UX 11.11

> Did u try putting remsh instead?

The popen used to use remsh until I was required to change it to ssh for security reasons.
skt_skt
Honored Contributor

Re: pclose hanging

but you may place it for testing; if thing work fine with remsh then definitly we have problems with ssh. I did have a similar problem while doing scp while rcp worked fine. Now we are upgrading both ssh (from A.04.20.004 to Shell-A.04.50.021 ) well as OS( from 11.11 to 11.23)
UnixTeam (Enbridge)
Occasional Contributor

Re: pclose hanging

Santhosh wrote:

> but you may place it for testing; if thing work fine with remsh then definitly we have problems with ssh.

We have probably 150 copies of this process running 24/7 on 30 or so different servers. The problem occurs maybe once or twice a week in total. It makes it difficult to test because even if the remsh runs without error for a year in one test configuration it won't prove that the problem is solved (since each individual process runs error free for 1 to 2 years average).

> I did have a similar problem while doing scp while rcp worked fine. Now we are upgrading both ssh (from A.04.20.004 to Shell-A.04.50.021 ) well as OS( from 11.11 to 11.23)

You say you had a similar problem with scp, could you give me a bit more detail on that?

I'll look into upgrading ssh and OS versions. I doubt if I'll have any luck in convincing anyone to do the OS upgrade but the ssh should be doable.
skt_skt
Honored Contributor

Re: pclose hanging

ssh upgrade is the one needed. we already had the OS upgrade in the plan and did both together.

go with this version 04.70.009 with HP-UX 11.11