kerravon86@yahoo.com.au [hercules-390]
2017-03-14 20:14:19 UTC
I discovered this issue in Hercules 3.07
but I looked at the Hercules 3.12 code
and it looks the same.
I suspect that this code:
if (dev->notrunc != 1)
{
open_flags |= O_TRUNC;
}
needs to have an:
else
{
open_flags |= O_APPEND;
}
Full code fragment is this:
(printer.c)
/*-------------------------------------------------------------------*/
/* Subroutine to open the printer file or pipe */
/*-------------------------------------------------------------------*/
static int
open_printer (DEVBLK *dev)
{
pid_t pid; /* Child process identifier */
char pathname[MAX_PATH]; /* file path in host format */
int open_flags; /* File open flags */
#if !defined( _MSVC_ )
int pipefd[2]; /* Pipe descriptors */
int rc; /* Return code */
#endif
/* Regular open if 1st char of filename is not vertical bar */
if (!dev->ispiped)
{
int fd;
/* Socket printer? */
if (dev->bs)
return (dev->fd < 0 ? -1 : 0);
/* Normal printer */
hostpath(pathname, dev->filename, sizeof(pathname));
open_flags = O_BINARY | O_WRONLY | O_CREAT /* | O_SYNC */;
if (dev->notrunc != 1)
{
open_flags |= O_TRUNC;
}
fd = open (pathname, open_flags,
S_IRUSR | S_IWUSR | S_IRGRP);
The symptom I am seeing is that
with this printer definition:
000F 1403 prt/prt00f.txt crlf noclear
(noting that "noclear" sets the
notrunc is set to true)
Anyway, if JOB 1 runs and has an
abend, and that abend output
goes to the printer and produces
a 1 MB file, and then I restart
Hercules and re-IPL MVS and
run JOB 2, which only produces
200 KB of data, then what I see
is that my output file remains
at 1 MB.
The first 200 KB is fine, it's the
data from JOB 2. But the last
800 KB is the last 800 KB of
JOB 1. ie the JOB 1 data has
been truncated.
What I actually expected, with
the noclear option in force, was
to get a 1.2 MB file, ie the first
1 MB contains the dump, and
the next 200 KB contains the
new output.
I can't see any possible use for
the current behavior which is to
just overwrite the beginning of
the file, leaving the last bit full
of old rubbish.
Let me know if you need me to
submit anything further.
Thanks. Paul.
but I looked at the Hercules 3.12 code
and it looks the same.
I suspect that this code:
if (dev->notrunc != 1)
{
open_flags |= O_TRUNC;
}
needs to have an:
else
{
open_flags |= O_APPEND;
}
Full code fragment is this:
(printer.c)
/*-------------------------------------------------------------------*/
/* Subroutine to open the printer file or pipe */
/*-------------------------------------------------------------------*/
static int
open_printer (DEVBLK *dev)
{
pid_t pid; /* Child process identifier */
char pathname[MAX_PATH]; /* file path in host format */
int open_flags; /* File open flags */
#if !defined( _MSVC_ )
int pipefd[2]; /* Pipe descriptors */
int rc; /* Return code */
#endif
/* Regular open if 1st char of filename is not vertical bar */
if (!dev->ispiped)
{
int fd;
/* Socket printer? */
if (dev->bs)
return (dev->fd < 0 ? -1 : 0);
/* Normal printer */
hostpath(pathname, dev->filename, sizeof(pathname));
open_flags = O_BINARY | O_WRONLY | O_CREAT /* | O_SYNC */;
if (dev->notrunc != 1)
{
open_flags |= O_TRUNC;
}
fd = open (pathname, open_flags,
S_IRUSR | S_IWUSR | S_IRGRP);
The symptom I am seeing is that
with this printer definition:
000F 1403 prt/prt00f.txt crlf noclear
(noting that "noclear" sets the
notrunc is set to true)
Anyway, if JOB 1 runs and has an
abend, and that abend output
goes to the printer and produces
a 1 MB file, and then I restart
Hercules and re-IPL MVS and
run JOB 2, which only produces
200 KB of data, then what I see
is that my output file remains
at 1 MB.
The first 200 KB is fine, it's the
data from JOB 2. But the last
800 KB is the last 800 KB of
JOB 1. ie the JOB 1 data has
been truncated.
What I actually expected, with
the noclear option in force, was
to get a 1.2 MB file, ie the first
1 MB contains the dump, and
the next 200 KB contains the
new output.
I can't see any possible use for
the current behavior which is to
just overwrite the beginning of
the file, leaving the last bit full
of old rubbish.
Let me know if you need me to
submit anything further.
Thanks. Paul.