PK64852: NEW FUNCTION

A fix is available

Subscribe

You can track all active APARs for this component.

APAR status

Closed as new function.

Error description

New Function APAR.

Local fix

Problem summary

****************************************************************
* USERS AFFECTED: All C/C++ applications that use pipes or *
* sockets to communicate between processes. *
****************************************************************
* PROBLEM DESCRIPTION: A hang condition may occur between two *
* processes that use pipes or sockets for *
* communication. *
* *
* The following is a scenario of an *
* example where the hang may occur: *
* *
* A parent and child process are using *
* pipes for communication purposes. The *
* child process wants to send a prompt to *
* the parent process and then read the *
* response. The parent must see the *
* prompt, capture a response, and then *
* send the response back to the child. *
* If the child sends the prompt without a *
* trailing newline or without calling *
* fflush, the prompt is never placed into *
* the pipe for the parent to read. The *
* child then tries to read the response. *
* The application hangs (parent cannot *
* read the prompt that it needs to *
* respond to and the child cannot read *
* the response from the parent). *
* *
* The same problem exists when sockets *
* are used in the scenario described *
* above. *
****************************************************************
* RECOMMENDATION: *
****************************************************************
See problem description.

Problem conclusion

Temporary fix

Comments

The following documentation update is required in the z/OS
XL C/C++ Programming Guide. Document number SC09-4765-08 and
newer versions.
Chapter 31. Using environment variables
AFTER _EDC_ERRNO_DIAG
ADD THE FOLLOWING:
_EDC_FLUSH_STDOUT_PIPE
Flush the stdout stream when the stdin stream is being read when
both are pipes.
ADD THE FOLLOWING:
_EDC_FLUSH_STDOUT_SOCKET
Flush the stdout stream when the stdin stream is being read when
both are sockets.
Chapter 31. Using environment variables
In Topic: Environment variables specific to the z/OS XL C/C++
library
Section: The z/OS XL C/C++ specific environment variables may
be set with the setenv() function.
In Subtopics:
after _EDC_ERRNO_DIAG
insert _EDC_FLUSH_STDOUT_PIPE
insert _EDC_FLUSH_STDOUT_SOCKET
Chapter 31. Using environment variables
Section 4.12.2.nn
AFTER _EDC_ERRNO_DIAG
ADD THE FOLLOWING:
_EDC_FLUSH_STDOUT_PIPE
Instructs the C runtime library to flush the stdout stream
when the stdin stream is being read from. Both stdin and stdout
must be pipes.
_EDC_FLUSH_STDOUT_PIPE is set with the command:
setenv("_EDC_FLUSH_STDOUT_PIPE","YES",1);
Usage scenario:
The purpose of this environment variable is to better facilitate
communication between two processes that use pipes. The child
process is using stdin for the read end of one pipe and stdout
for the write end of a different pipe. The parent process has
the opposite ends of the pipes. The following is a possible
example of the communication:
The child process wants to send a prompt to the parent process
and then read the response. The parent must see the prompt,
capture a response, and then send the response back to the
child. If the child sends the prompt without a trailing
newline or without calling fflush, the prompt is never placed
into the pipe for the parent to read. The child then tries to
read the response from stdin. The application hangs (parent
cannot read the prompt that it needs to respond to and the
child cannot read the response from the parent). With the
environment variable set to YES, the read from stdin will flush
the stdout buffer. This allows the parent to see the prompt,
respond, then send the response back to the child who is waiting
on the read. Since the data comes back from the parent, the
child reads the response and continues. It should be mentioned
that the parent process must do a read() from the pipe so that
it can receive whatever data might be there without having to
wait for a specific number of bytes or a newline character.
Functions like fread() and fgets() will hang unless the child
wrote enough bytes or the newline character to stdout.
ADD THE FOLLOWING:
_EDC_FLUSH_STDOUT_SOCKET
Instructs the C runtime library to flush the stdout stream
when the stdin stream is being read from. Both stdin and stdout
must be sockets.
_EDC_FLUSH_STDOUT_SOCKET is set with the command:
setenv("_EDC_FLUSH_STDOUT_SOCKET","YES",1);
Usage scenario:
The purpose of this environment variable is to better facilitate
communication between two processes that use sockets. The child
process is using stdin for the read end of one socket and stdout
for the write end of a different socket. The parent process has
the opposite ends of the sockets. The following is a possible
example of the communication:
The child process wants to send a prompt to the parent process
and then read the response. The parent must see the prompt,
capture a response, and then send the response back to the
child. If the child sends the prompt without a trailing
newline or without calling fflush, the prompt is never placed
into the socket for the parent to read. The child then tries to
read the response from stdin. The application hangs (parent
cannot read the prompt that it needs to respond to and the
child cannot read the response from the parent). With the
environment variable set to YES, the read from stdin will flush
the stdout buffer. This allows the parent to see the prompt,
respond, then send the response back to the child who is waiting
on the read. Since the data comes back from the parent, the
child reads the response and continues. It should be mentioned
that the parent process must do a read() from the socket so that
it can receive whatever data might be there without having to
wait for a specific number of bytes or a newline character.
Functions like fread() and fgets() will hang unless the child
wrote enough bytes or the newline character to stdout.