Discussion:
PROCESS_SPAWN_ weirdness
(too old to reply)
Randall
2021-02-08 19:37:37 UTC
Permalink
Hi All,

I'm trying to use PROCESS_SPAWN_ from GUARDIAN. Normally there are no issues when I am setting stdout of the created child to a process name or SSH tty. However, when I specify an OSS path for stdout, whether the file exists or not, the file is appended to the cwd and the process fails being unable to open stdout, with either an error 4002 (no such file) if I don't pre-create the file, or 4021 (is a directory, which it's not) if I do.

/* Build the fdinfo entry for stdout */
fdentry[1].z_fd = 1;
fdentry[1].z_dupfd = -1;
fdentry[1].z_name = "/tmp/test.out";
fdentry[1].z_oflag = O_WRONLY;
fdentry[1].z_mode = 0755;

The 4002 is reported on /home/randall//tmp/test.out. This one has me scratching my head. Any thoughts?

TIA,
Randall
Keith Dick
2021-02-09 00:38:36 UTC
Permalink
Post by Randall
Hi All,
I'm trying to use PROCESS_SPAWN_ from GUARDIAN. Normally there are no issues when I am setting stdout of the created child to a process name or SSH tty. However, when I specify an OSS path for stdout, whether the file exists or not, the file is appended to the cwd and the process fails being unable to open stdout, with either an error 4002 (no such file) if I don't pre-create the file, or 4021 (is a directory, which it's not) if I do.
/* Build the fdinfo entry for stdout */
fdentry[1].z_fd = 1;
fdentry[1].z_dupfd = -1;
fdentry[1].z_name = "/tmp/test.out";
fdentry[1].z_oflag = O_WRONLY;
fdentry[1].z_mode = 0755;
The 4002 is reported on /home/randall//tmp/test.out. This one has me scratching my head. Any thoughts?
TIA,
Randall
I've no experience in this area, but I wonder whether the fact that the mode you are giving allows both read and write while the flag is write-only has anything to do with the problem.
JShepherd
2021-02-09 16:46:35 UTC
Permalink
Post by Randall
Hi All,
I'm trying to use PROCESS_SPAWN_ from GUARDIAN. Normally there are no issue=
s when I am setting stdout of the created child to a process name or SSH tt=
y. However, when I specify an OSS path for stdout, whether the file exists =
or not, the file is appended to the cwd and the process fails being unable =
to open stdout, with either an error 4002 (no such file) if I don't pre-cre=
ate the file, or 4021 (is a directory, which it's not) if I do.
/* Build the fdinfo entry for stdout */
fdentry[1].z_fd =3D 1;
fdentry[1].z_dupfd =3D -1;
fdentry[1].z_name =3D "/tmp/test.out";
fdentry[1].z_oflag =3D O_WRONLY;
fdentry[1].z_mode =3D 0755;
The 4002 is reported on /home/randall//tmp/test.out. This one has me scratc=
hing my head. Any thoughts?
TIA,
Randall
Never seen that happen but we don't set mode
and we set access to read/write

fd->z_fd = 1; /* stdout */
fd->z_dupfd = -1; /* not a dup, must be opened */
fd->z_name = (long)outfile;
fd->z_oflag = ZSYS_VAL_OSSOPEN_RDWR;
fd->z_mode = 0;
fd++;
fdinfo->z_fdcount++;
JShepherd
2021-02-09 17:00:58 UTC
Permalink
Post by Randall
Hi All,
I'm trying to use PROCESS_SPAWN_ from GUARDIAN. Normally there are no issue=
s when I am setting stdout of the created child to a process name or SSH tt=
y. However, when I specify an OSS path for stdout, whether the file exists =
or not, the file is appended to the cwd and the process fails being unable =
to open stdout, with either an error 4002 (no such file) if I don't pre-cre=
ate the file, or 4021 (is a directory, which it's not) if I do.
/* Build the fdinfo entry for stdout */
fdentry[1].z_fd =3D 1;
fdentry[1].z_dupfd =3D -1;
fdentry[1].z_name =3D "/tmp/test.out";
fdentry[1].z_oflag =3D O_WRONLY;
fdentry[1].z_mode =3D 0755;
The 4002 is reported on /home/randall//tmp/test.out. This one has me scratc=
hing my head. Any thoughts?
TIA,
Randall
Maybe you have to OR in
ZSYS_VAL_OSSOPEN_CREAT
to z_flag
Randall
2021-02-09 21:46:30 UTC
Permalink
Post by JShepherd
Post by Randall
Hi All,
I'm trying to use PROCESS_SPAWN_ from GUARDIAN. Normally there are no issue=
s when I am setting stdout of the created child to a process name or SSH tt=
y. However, when I specify an OSS path for stdout, whether the file exists =
or not, the file is appended to the cwd and the process fails being unable =
to open stdout, with either an error 4002 (no such file) if I don't pre-cre=
ate the file, or 4021 (is a directory, which it's not) if I do.
/* Build the fdinfo entry for stdout */
fdentry[1].z_fd =3D 1;
fdentry[1].z_dupfd =3D -1;
fdentry[1].z_name =3D "/tmp/test.out";
fdentry[1].z_oflag =3D O_WRONLY;
fdentry[1].z_mode =3D 0755;
The 4002 is reported on /home/randall//tmp/test.out. This one has me scratc=
hing my head. Any thoughts?
TIA,
Randall
Maybe you have to OR in
ZSYS_VAL_OSSOPEN_CREAT
to z_flag
It was O_CREAT from fdentry[1].z_oflag that I was missing and did the trick.

The stdout descriptor should not be opened for read, normally. That causes all kinds
of issues when interacting with OSS processes like Jenkins.

The appended file name was an artifact of reporting failure, not the cause. Whew.

Thanks for the help.
Randall

Continue reading on narkive:
Loading...