Temp file frustration

Post Reply

Topic author
jhamby
Contributor
Posts: 22
Joined: Wed Oct 04, 2023 8:59 pm
Reputation: 0
Status: Offline

Temp file frustration

Post by jhamby » Wed Nov 15, 2023 3:55 pm

I recently posted about an issue with redirecting stdout and stderr of a child process to a file. The suggestion I received was to open the file for output, close it, reopen it for reading, then call decc$set_child_standard_streams(-1, fd, fd) in the parent before calling exec(), then close the file in the parent. The reason the parent can't have the file open for writing is that it causes a file locking error in the child.

I followed that strategy with the test harness for libuv, and ran into additional problems. First, I couldn't use tmpfile() because it creates a file named ".", which confuses git into failing with unrecoverable errors if it sees that filename in the tree. So that's the first bug I ran into.

I already had an implementation of mkdtemp() in this project, copied from the z/OS port, so I used it to generate random temp filenames. What I discovered is that I couldn't redirect both stdout and stderr because the child opened the existing file for stdout and then created a new file with a higher version number for stderr. Then the parent opened that file and could only see the child's stderr and not its stdout. So I had to choose one or the other to redirect.

What's even stranger, and I apologize for not being able to write a standalone test case to repro this, is that the parent process is creating an empty directory with the same name as the temp file plus ".DIR". I noticed this with some of the temp files that Perl's unit tests were creating as well.

I tried to see what was going on with "set watch file/class=(all,nodump)" and it looks like the parent is creating the directory in the process of scanning. It's very strange. Here's what my standalone test program, which works, looks like:

Code: Select all

%XQP, Thread #0, Volume protection: Access requested: 00000001, Status: 00000001, PrvUsd: 00000000
%XQP, Thread #0, File protection (15582,3,0): Access requested: 00000004, Status: 00000001, PrvUsd: 00000000
%XQP, Thread #0, Read only directory access (15582,3,0)
%XQP, Thread #0, Directory scan for: tmpfile_0Gq8n9.;0, Status: 00000000
%XQP, Thread #0, Lookup  (0,0,0) Status: 00000910
%XQP, Thread #0, Volume protection: Access requested: 00000001, Status: 00000001, PrvUsd: 00000000
%XQP, Thread #0, File protection (15582,3,0): Access requested: 00000004, Status: 00000001, PrvUsd: 00000000
%XQP, Thread #0, Read only directory access (15582,3,0)
%XQP, Thread #0, Directory scan for: tmpfile_0Gq8n9.DIR;0, Status: 00000000
%XQP, Thread #0, Lookup  (0,0,0) Status: 00000910
%XQP, Thread #0, Volume protection: Access requested: 00000001, Status: 00000001, PrvUsd: 00000000
%XQP, Thread #0, File protection (15582,3,0): Access requested: 00000004, Status: 00000001, PrvUsd: 00000000
%XQP, Thread #0, Read only directory access (15582,3,0)
%XQP, Thread #0, Directory scan for: tmpfile_0Gq8n9.;0, Status: 00000000
%XQP, Thread #0, Read only directory access (15582,3,0)
%XQP, Thread #0, Directory scan for: tmpfile_0Gq8n9.;0, Status: 00000000
%XQP, Thread #0, Volume protection: Access requested: 00000007, Status: 00000001, PrvUsd: 00000000
%XQP, Thread #0, File protection (15582,3,0): Access requested: 00000003, Status: 00000001, PrvUsd: 00000000
%XQP, Thread #0, Read/write directory access (15582,3,0)
%XQP, Thread #0, Directory scan for: tmpfile_0Gq8n9.;0, Status: 00000000
%XQP, Thread #0, Create new directory entry
%XQP, Thread #0, Write attributes: Creation date tmpfile_0Gq8n9.;1 (106982,2,0)
%XQP, Thread #0, Write attributes: Expiration date tmpfile_0Gq8n9.;1 (106982,2,0)
%XQP, Thread #0, Write attributes: Backup date tmpfile_0Gq8n9.;1 (106982,2,0)
%XQP, Thread #0, Write attributes: Last access date/time tmpfile_0Gq8n9.;1 (106982,2,0)
%XQP, Thread #0, Write attributes: Last attribute update date/time tmpfile_0Gq8n9.;1 (106982,2,0)
%XQP, Thread #0, Write attributes: Data modification date/time tmpfile_0Gq8n9.;1 (106982,2,0)
%XQP, Thread #0, Write attributes: Revision date tmpfile_0Gq8n9.;1 (106982,2,0)
%XQP, Thread #0, Write attributes: ASCII dates tmpfile_0Gq8n9.;1 (106982,2,0)
%XQP, Thread #0, Write attributes: Journal flags tmpfile_0Gq8n9.;1 (106982,2,0)
%XQP, Thread #0, Write attributes: RU active tmpfile_0Gq8n9.;1 (106982,2,0)
%XQP, Thread #0, Write attributes: Statistics block tmpfile_0Gq8n9.;1 (106982,2,0)
%XQP, Thread #0, Write attributes: Find ACE by type tmpfile_0Gq8n9.;1 (106982,2,0)
%XQP, Thread #0, Write attributes: Record attributes tmpfile_0Gq8n9.;1 (106982,2,0)
%XQP, Thread #0, Write attributes: User file characteristics tmpfile_0Gq8n9.;1 (106982,2,0)
%XQP, Thread #0, Write attributes: File length hint field tmpfile_0Gq8n9.;1 (106982,2,0)
%XQP, Thread #0, Write attributes: Symlink meta-data tmpfile_0Gq8n9.;1 (106982,2,0)
%XQP, Thread #0, Create-if Create/Access tmpfile_0Gq8n9.;1 (106982,2,0) Status: 00000619
%XQP, Thread #0, Control function  (106982,2,0) Status: 00000001
%XQP, Thread #0, Final status: 00000870
%XQP, Thread #0, Modify tmpfile_0Gq8n9.;1 (106982,2,0) Status: 00000001
%XQP, Thread #0, Write attributes: Record attributes tmpfile_0Gq8n9.;1 (106982,2,0)
%XQP, Thread #0, Deaccess (106982,2,0) Reads: 1, Writes: 2, Status: 00000001
%XQP, Thread #0, Volume protection: Access requested: 00000001, Status: 00000001, PrvUsd: 00000000
%XQP, Thread #0, File protection (15582,3,0): Access requested: 00000004, Status: 00000001, PrvUsd: 00000000
%XQP, Thread #0, Read only directory access (15582,3,0)
%XQP, Thread #0, Directory scan for: tmpfile_0Gq8n9.;0, Status: 00000001
%XQP, Thread #0, File protection (106982,2,0): Access requested: 00000001, Status: 00000001, PrvUsd: 00000000
%XQP, Thread #0, Read attributes: Access mode tmpfile_0Gq8n9.;1 (106982,2,0)
%XQP, Thread #0, Read attributes: Creation date tmpfile_0Gq8n9.;1 (106982,2,0)
%XQP, Thread #0, Read attributes: Expiration date tmpfile_0Gq8n9.;1 (106982,2,0)
%XQP, Thread #0, Read attributes: Backup date tmpfile_0Gq8n9.;1 (106982,2,0)
%XQP, Thread #0, Read attributes: Last access date/time tmpfile_0Gq8n9.;1 (106982,2,0)
%XQP, Thread #0, Read attributes: Last attribute update date/time tmpfile_0Gq8n9.;1 (106982,2,0)
%XQP, Thread #0, Read attributes: Data modification date/time tmpfile_0Gq8n9.;1 (106982,2,0)
%XQP, Thread #0, Read attributes: Revision date tmpfile_0Gq8n9.;1 (106982,2,0)
%XQP, Thread #0, Read attributes: ASCII dates tmpfile_0Gq8n9.;1 (106982,2,0)
%XQP, Thread #0, Read attributes: Access mode tmpfile_0Gq8n9.;1 (106982,2,0)
%XQP, Thread #0, Read attributes: Journal flags tmpfile_0Gq8n9.;1 (106982,2,0)
%XQP, Thread #0, Read attributes: RU active tmpfile_0Gq8n9.;1 (106982,2,0)
%XQP, Thread #0, Read attributes: Statistics block tmpfile_0Gq8n9.;1 (106982,2,0)
%XQP, Thread #0, Read attributes: Find ACE by type tmpfile_0Gq8n9.;1 (106982,2,0)
%XQP, Thread #0, Read attributes: Record attributes tmpfile_0Gq8n9.;1 (106982,2,0)
%XQP, Thread #0, Read attributes: User file characteristics tmpfile_0Gq8n9.;1 (106982,2,0)
%XQP, Thread #0, Read attributes: File length hint field tmpfile_0Gq8n9.;1 (106982,2,0)
%XQP, Thread #0, Read attributes: Symlink meta-data tmpfile_0Gq8n9.;1 (106982,2,0)
%XQP, Thread #0, Access tmpfile_0Gq8n9.;1 (106982,2,0) Status: 00000001
%XQP, Thread #0, Control function  (106982,2,0) Status: 00000001
%XQP, Thread #0, Final status: 00000870
%XQP, Thread #0, Volume protection: Access requested: 00000001, Status: 00000001, PrvUsd: 00000000
%XQP, Thread #0, File protection (15582,3,0): Access requested: 00000004, Status: 00000001, PrvUsd: 00000000
%XQP, Thread #0, Read only directory access (15582,3,0)
%XQP, Thread #0, Directory scan for: child.exe;0, Status: 00000001
%XQP, Thread #0, File protection (105383,3,0): Access requested: 00000001, Status: 00000001, PrvUsd: 00000000
%XQP, Thread #0, Read attributes: Access mode child.exe;1 (105383,3,0)
%XQP, Thread #0, Read attributes: Creation date child.exe;1 (105383,3,0)
%XQP, Thread #0, Read attributes: Expiration date child.exe;1 (105383,3,0)
%XQP, Thread #0, Read attributes: Backup date child.exe;1 (105383,3,0)
%XQP, Thread #0, Read attributes: Last access date/time child.exe;1 (105383,3,0)
%XQP, Thread #0, Read attributes: Last attribute update date/time child.exe;1 (105383,3,0)
%XQP, Thread #0, Read attributes: Data modification date/time child.exe;1 (105383,3,0)
%XQP, Thread #0, Read attributes: Revision date child.exe;1 (105383,3,0)
%XQP, Thread #0, Read attributes: ASCII dates child.exe;1 (105383,3,0)
%XQP, Thread #0, Read attributes: Access mode child.exe;1 (105383,3,0)
%XQP, Thread #0, Read attributes: Journal flags child.exe;1 (105383,3,0)
%XQP, Thread #0, Read attributes: RU active child.exe;1 (105383,3,0)
%XQP, Thread #0, Read attributes: Statistics block child.exe;1 (105383,3,0)
%XQP, Thread #0, Read attributes: Find ACE by type child.exe;1 (105383,3,0)
%XQP, Thread #0, Read attributes: Record attributes child.exe;1 (105383,3,0)
%XQP, Thread #0, Read attributes: User file characteristics child.exe;1 (105383,3,0)
%XQP, Thread #0, Read attributes: File length hint field child.exe;1 (105383,3,0)
%XQP, Thread #0, Read attributes: Symlink meta-data child.exe;1 (105383,3,0)
%XQP, Thread #0, Access child.exe;1 (105383,3,0) Status: 00000001
%XQP, Thread #0, Control function  (105383,3,0) Status: 00000001
%XQP, Thread #0, Deaccess (105383,3,0) Reads: 1, Writes: 0, Status: 00000001
%XQP, Thread #0, Read attributes: Access mode tmpfile_0Gq8n9.;1 (106982,2,0)
%XQP, Thread #0, Read attributes: hardlink count tmpfile_0Gq8n9.;1 (106982,2,0)
%XQP, Thread #0, Read attributes: Creation date tmpfile_0Gq8n9.;1 (106982,2,0)
%XQP, Thread #0, Read attributes: Expiration date tmpfile_0Gq8n9.;1 (106982,2,0)
%XQP, Thread #0, Read attributes: Backup date tmpfile_0Gq8n9.;1 (106982,2,0)
%XQP, Thread #0, Read attributes: Last access date/time tmpfile_0Gq8n9.;1 (106982,2,0)
%XQP, Thread #0, Read attributes: Last attribute update date/time tmpfile_0Gq8n9.;1 (106982,2,0)
%XQP, Thread #0, Read attributes: Data modification date/time tmpfile_0Gq8n9.;1 (106982,2,0)
%XQP, Thread #0, Read attributes: Revision date tmpfile_0Gq8n9.;1 (106982,2,0)
%XQP, Thread #0, Read attributes: ASCII dates tmpfile_0Gq8n9.;1 (106982,2,0)
%XQP, Thread #0, Lookup tmpfile_0Gq8n9.;1 (106982,2,0) Status: 00000001
%XQP, Thread #0, Read attributes: Access mode tmpfile_0Gq8n9.;1 (106982,2,0)
%XQP, Thread #0, Read attributes: Owner UIC tmpfile_0Gq8n9.;1 (106982,2,0)
%XQP, Thread #0, Read attributes: Header 1 accessibility tmpfile_0Gq8n9.;1 (106982,2,0)
%XQP, Thread #0, Read attributes: File protection tmpfile_0Gq8n9.;1 (106982,2,0)
%XQP, Thread #0, Read attributes: File access level tmpfile_0Gq8n9.;1 (106982,2,0)
%XQP, Thread #0, Read attributes: ACL length tmpfile_0Gq8n9.;1 (106982,2,0)
%XQP, Thread #0, Read attributes: Statistics block tmpfile_0Gq8n9.;1 (106982,2,0)
%XQP, Thread #0, Read attributes: Record attributes tmpfile_0Gq8n9.;1 (106982,2,0)
%XQP, Thread #0, Read attributes: Access mode tmpfile_0Gq8n9.;1 (106982,2,0)
%XQP, Thread #0, Read attributes: Journal flags tmpfile_0Gq8n9.;1 (106982,2,0)
%XQP, Thread #0, Read attributes: RU active tmpfile_0Gq8n9.;1 (106982,2,0)
%XQP, Thread #0, Lookup tmpfile_0Gq8n9.;1 (106982,2,0) Status: 00000001
%XQP, Thread #0, Volume protection: Access requested: 00000001, Status: 00000001, PrvUsd: 00000000
The parent creates the temp file and the child accesses it, as expected. But for "uv_run_tests", I get this:

Code: Select all

%XQP, Thread #0, Volume protection: Access requested: 00000001, Status: 00000001, PrvUsd: 00000000
%XQP, Thread #0, File protection (114201,1,0): Access requested: 00000004, Status: 00000001, PrvUsd: 00000000
%XQP, Thread #0, Read only directory access (114201,1,0)
%XQP, Thread #0, Directory scan for: tmpfile_iz44I0.;0, Status: 00000000
%XQP, Thread #0, Access  (0,0,0) Status: 00000910
%XQP, Thread #0, Volume protection: Access requested: 00000007, Status: 00000001, PrvUsd: 00000000
%XQP, Thread #0, File protection (114201,1,0): Access requested: 00000003, Status: 00000001, PrvUsd: 00000000
%XQP, Thread #0, Read/write directory access (114201,1,0)
%XQP, Thread #0, Directory scan for: tmpfile_iz44I0.DIR;1, Status: 00000000
%XQP, Thread #0, Create new directory entry
%XQP, Thread #0, Write attributes: Record attributes tmpfile_iz44I0.DIR;1 (4096,246,0)
%XQP, Thread #0, Write attributes: User file characteristics tmpfile_iz44I0.DIR;1 (4096,246,0)
%XQP, Thread #0, Write attributes: File protection tmpfile_iz44I0.DIR;1 (4096,246,0)
%XQP, Thread #0, Create directory tmpfile_iz44I0.DIR;1 (4096,246,0) Status: 00000001
%XQP, Thread #0, Volume protection: Access requested: 00000001, Status: 00000001, PrvUsd: 00000000
%XQP, Thread #0, File protection (20,20,0): Access requested: 00000004, Status: 00000001, PrvUsd: 00000000
%XQP, Thread #0, Read only directory access (20,20,0)
%XQP, Thread #0, Directory scan for: Projects.;0, Status: 00000000
%XQP, Thread #0, Directory scan for: Projects.DIR;1, Status: 00000001
%XQP, Thread #0, File protection (2002,649,0): Access requested: 00000004, Status: 00000001, PrvUsd: 00000000
%XQP, Thread #0, Read attributes: Record attributes Projects.DIR;1 (2002,649,0)
%XQP, Thread #0, Read attributes: User file characteristics Projects.DIR;1 (2002,649,0)
%XQP, Thread #0, Read attributes: Symlink meta-data Projects.DIR;1 (2002,649,0)
%XQP, Thread #0, Lookup Projects.DIR;1 (2002,649,0) Status: 00000001
%XQP, Thread #0, Volume protection: Access requested: 00000001, Status: 00000001, PrvUsd: 00000000
%XQP, Thread #0, File protection (114201,1,0): Access requested: 00000004, Status: 00000001, PrvUsd: 00000000
%XQP, Thread #0, Read only directory access (114201,1,0)
%XQP, Thread #0, Directory scan for: tmpfile_iz44I0.;0, Status: 00000000
%XQP, Thread #0, Lookup  (2002,649,0) Status: 00000910
%XQP, Thread #0, Volume protection: Access requested: 00000001, Status: 00000001, PrvUsd: 00000000
%XQP, Thread #0, File protection (114201,1,0): Access requested: 00000004, Status: 00000001, PrvUsd: 00000000
%XQP, Thread #0, Read only directory access (114201,1,0)
%XQP, Thread #0, Directory scan for: tmpfile_iz44I0.DIR;0, Status: 00000001
%XQP, Thread #0, Lookup  (4096,246,0) Status: 00000001
%XQP, Thread #0, Volume protection: Access requested: 00000001, Status: 00000001, PrvUsd: 00000000
%XQP, Thread #0, File protection (4096,246,0): Access requested: 00000001, Status: 00000001, PrvUsd: 00000000
%XQP, Thread #0, Read attributes: User file characteristics tmpfile_iz44I0.DIR;1 (4096,246,0)
%XQP, Thread #0, Access tmpfile_iz44I0.DIR;1 (4096,246,0) Status: 00000001
%XQP, Thread #0, Deaccess (4096,246,0) Reads: 0, Writes: 0, Status: 00000001
%XQP, Thread #0, Volume protection: Access requested: 00000001, Status: 00000001, PrvUsd: 00000000
%XQP, Thread #0, File protection (4096,246,0): Access requested: 00000001, Status: 00000001, PrvUsd: 00000000
%XQP, Thread #0, Read attributes: Creation date tmpfile_iz44I0.DIR;1 (4096,246,0)
%XQP, Thread #0, Read attributes: Revision date tmpfile_iz44I0.DIR;1 (4096,246,0)
%XQP, Thread #0, Read attributes: Record attributes tmpfile_iz44I0.DIR;1 (4096,246,0)
%XQP, Thread #0, Read attributes: Owner UIC tmpfile_iz44I0.DIR;1 (4096,246,0)
%XQP, Thread #0, Read attributes: File protection tmpfile_iz44I0.DIR;1 (4096,246,0)
%XQP, Thread #0, Read attributes: User file characteristics tmpfile_iz44I0.DIR;1 (4096,246,0)
%XQP, Thread #0, Read attributes: hardlink count tmpfile_iz44I0.DIR;1 (4096,246,0)
%XQP, Thread #0, Lookup tmpfile_iz44I0.DIR;1 (4096,246,0) Status: 00000001
%XQP, Thread #0, Volume protection: Access requested: 00000001, Status: 00000001, PrvUsd: 00000000
%XQP, Thread #0, File protection (114201,1,0): Access requested: 00000004, Status: 00000001, PrvUsd: 00000000
%XQP, Thread #0, Read only directory access (114201,1,0)
%XQP, Thread #0, Directory scan for: tmpfile_iz44I0.;0, Status: 00000000
%XQP, Thread #0, Read only directory access (114201,1,0)
%XQP, Thread #0, Directory scan for: tmpfile_iz44I0.;0, Status: 00000000
%XQP, Thread #0, Volume protection: Access requested: 00000007, Status: 00000001, PrvUsd: 00000000
%XQP, Thread #0, File protection (114201,1,0): Access requested: 00000003, Status: 00000001, PrvUsd: 00000000
%XQP, Thread #0, Read/write directory access (114201,1,0)
%XQP, Thread #0, Directory scan for: tmpfile_iz44I0.;0, Status: 00000000
%XQP, Thread #0, Create new directory entry
%XQP, Thread #0, Write attributes: Creation date tmpfile_iz44I0.;1 (52676,1521,0)
%XQP, Thread #0, Write attributes: Expiration date tmpfile_iz44I0.;1 (52676,1521,0)
%XQP, Thread #0, Write attributes: Backup date tmpfile_iz44I0.;1 (52676,1521,0)
%XQP, Thread #0, Write attributes: Last access date/time tmpfile_iz44I0.;1 (52676,1521,0)
%XQP, Thread #0, Write attributes: Last attribute update date/time tmpfile_iz44I0.;1 (52676,1521,0)
%XQP, Thread #0, Write attributes: Data modification date/time tmpfile_iz44I0.;1 (52676,1521,0)
%XQP, Thread #0, Write attributes: Revision date tmpfile_iz44I0.;1 (52676,1521,0)
%XQP, Thread #0, Write attributes: ASCII dates tmpfile_iz44I0.;1 (52676,1521,0)
%XQP, Thread #0, Write attributes: Journal flags tmpfile_iz44I0.;1 (52676,1521,0)
%XQP, Thread #0, Write attributes: RU active tmpfile_iz44I0.;1 (52676,1521,0)
%XQP, Thread #0, Write attributes: Statistics block tmpfile_iz44I0.;1 (52676,1521,0)
%XQP, Thread #0, Write attributes: Find ACE by type tmpfile_iz44I0.;1 (52676,1521,0)
%XQP, Thread #0, Write attributes: Record attributes tmpfile_iz44I0.;1 (52676,1521,0)
%XQP, Thread #0, Write attributes: User file characteristics tmpfile_iz44I0.;1 (52676,1521,0)
%XQP, Thread #0, Write attributes: File length hint field tmpfile_iz44I0.;1 (52676,1521,0)
%XQP, Thread #0, Write attributes: Symlink meta-data tmpfile_iz44I0.;1 (52676,1521,0)
%XQP, Thread #0, Create-if Create/Access tmpfile_iz44I0.;1 (52676,1521,0) Status: 00000619
%XQP, Thread #0, Control function  (52676,1521,0) Status: 00000001
%XQP, Thread #0, Final status: 00000870
%XQP, Thread #0, Write attributes: Record attributes tmpfile_iz44I0.;1 (52676,1521,0)
%XQP, Thread #0, Deaccess (52676,1521,0) Reads: 1, Writes: 0, Status: 00000001
%XQP, Thread #0, Volume protection: Access requested: 00000001, Status: 00000001, PrvUsd: 00000000
%XQP, Thread #0, File protection (114201,1,0): Access requested: 00000004, Status: 00000001, PrvUsd: 00000000
%XQP, Thread #0, Read only directory access (114201,1,0)
%XQP, Thread #0, Directory scan for: tmpfile_iz44I0.;0, Status: 00000001
%XQP, Thread #0, File protection (52676,1521,0): Access requested: 00000001, Status: 00000001, PrvUsd: 00000000
%XQP, Thread #0, Read attributes: Access mode tmpfile_iz44I0.;1 (52676,1521,0)
%XQP, Thread #0, Read attributes: Creation date tmpfile_iz44I0.;1 (52676,1521,0)
%XQP, Thread #0, Read attributes: Expiration date tmpfile_iz44I0.;1 (52676,1521,0)
%XQP, Thread #0, Read attributes: Backup date tmpfile_iz44I0.;1 (52676,1521,0)
%XQP, Thread #0, Read attributes: Last access date/time tmpfile_iz44I0.;1 (52676,1521,0)
%XQP, Thread #0, Read attributes: Last attribute update date/time tmpfile_iz44I0.;1 (52676,1521,0)
%XQP, Thread #0, Read attributes: Data modification date/time tmpfile_iz44I0.;1 (52676,1521,0)
%XQP, Thread #0, Read attributes: Revision date tmpfile_iz44I0.;1 (52676,1521,0)
%XQP, Thread #0, Read attributes: ASCII dates tmpfile_iz44I0.;1 (52676,1521,0)
%XQP, Thread #0, Read attributes: Access mode tmpfile_iz44I0.;1 (52676,1521,0)
%XQP, Thread #0, Read attributes: Journal flags tmpfile_iz44I0.;1 (52676,1521,0)
%XQP, Thread #0, Read attributes: RU active tmpfile_iz44I0.;1 (52676,1521,0)
%XQP, Thread #0, Read attributes: Statistics block tmpfile_iz44I0.;1 (52676,1521,0)
%XQP, Thread #0, Read attributes: Find ACE by type tmpfile_iz44I0.;1 (52676,1521,0)
%XQP, Thread #0, Read attributes: Record attributes tmpfile_iz44I0.;1 (52676,1521,0)
%XQP, Thread #0, Read attributes: User file characteristics tmpfile_iz44I0.;1 (52676,1521,0)
%XQP, Thread #0, Read attributes: File length hint field tmpfile_iz44I0.;1 (52676,1521,0)
%XQP, Thread #0, Read attributes: Symlink meta-data tmpfile_iz44I0.;1 (52676,1521,0)
%XQP, Thread #0, Access tmpfile_iz44I0.;1 (52676,1521,0) Status: 00000001
%XQP, Thread #0, Control function  (52676,1521,0) Status: 00000001
%XQP, Thread #0, Final status: 00000870
%XQP, Thread #0, Volume protection: Access requested: 00000001, Status: 00000001, PrvUsd: 00000000
%XQP, Thread #0, File protection (114201,1,0): Access requested: 00000004, Status: 00000001, PrvUsd: 00000000
%XQP, Thread #0, Read only directory access (114201,1,0)
The unwanted directory is being created by the parent just before it creates the temp file, before the child starts (for this test run, I didn't exec the child at all). The test harness isn't doing very much before this point, so I'm not sure what the difference is from my standalone test. As I mentioned, I saw this with Perl as well. Both of the above logs start immediately after LIBCXXABI.EXE has been accessed. I'm using C++ on OpenVMS V9.2-1 with all the updates available to download. I'm using these DECC$ logicals.

"DECC$ARGV_PARSE_STYLE" = "enable"
"DECC$EFS_CASE_PRESERVE" = "enable"
"DECC$EFS_CHARSET" = "enable"
"DECC$FD_LOCKING" = "true"

My source repo with the current version of the port is here: https://github.com/jhamby/vms-libuv


pustovetov
VSI Expert
Contributor
Posts: 18
Joined: Thu Sep 14, 2023 1:26 am
Reputation: 0
Status: Offline

Re: Temp file frustration

Post by pustovetov » Thu Nov 16, 2023 9:36 am

jhamby wrote:
Wed Nov 15, 2023 3:55 pm
I followed that strategy with the test harness for libuv, and ran into additional problems. First, I couldn't use tmpfile() because it creates a file named ".", which confuses git into failing with unrecoverable errors if it sees that filename in the tree. So that's the first bug I ran into.
Oops. Yes, I see we are opening a temporary file in a very strange way. I have to check and fix it.
I already had an implementation of mkdtemp() in this project, copied from the z/OS port, so I used it to generate random temp filenames. What I discovered is that I couldn't redirect both stdout and stderr because the child opened the existing file for stdout and then created a new file with a higher version number for stderr. Then the parent opened that file and could only see the child's stderr and not its stdout. So I had to choose one or the other to redirect.
Yes, I'll try to fix issues with redirecting to stderr. This probably won't be a very complicated bug fix.
What's even stranger, and I apologize for not being able to write a standalone test case to repro this, is that the parent process is creating an empty directory with the same name as the temp file plus ".DIR". I noticed this with some of the temp files that Perl's unit tests were creating as well.
It's a really strange behavior. I should see your sources.

Vitaly


Topic author
jhamby
Contributor
Posts: 22
Joined: Wed Oct 04, 2023 8:59 pm
Reputation: 0
Status: Offline

Re: Temp file frustration

Post by jhamby » Wed Nov 22, 2023 11:25 am

I just posted a commit to my fork of the libuv sources that has good performance (the temp file creation is only used for running test cases and benchmarks, fortunately), so I may return to the temp directory creation issue bug later.

https://github.com/jhamby/vms-libuv

As I said, I couldn't figure out a standalone way to repro the creation of the empty .DIR with the same name as the temp file, but it does show up in VMS Perl as well as my new port, so I can reasonably assume it doesn't have to do with DECC$ flag settings, since Perl sets several of them in lib$initialize startup, and libuv isn't setting any.

I tried adding a filename extension, like ".txt", but then directories with names ending in e.g. "^.txt.DIR" are created.

Post Reply