Euphoria
Ticket #938:
copy_file eats file handles
-
Reported by
SDPringle
Oct 30, 2015
The routine copy_file leaves files open in some circumstances. If it can open the destination but not the source or vice versa. Also when the source is a directory. a null-file is created for the destination.
-- this would create a regular file in $HOME/usr of length 0
copy_file("/usr", getenv("HOME") & "/usr")
-- this would cause a run-out-of file handles error
-- don't run this as root. :)
while 1 do
copy_file("/dev/null", "/foo")
end while
How should copy_file handle the case where the source is a destination? Do a recursive copy or return an error code?
Details
1. Comment by SDPringle
Nov 06, 2015
On Linux, when you open a file and you close it, the next time you open any file you will get the same file handle number. I would like to take advantage of this but I don't know whethe this behaviour guaranteed through OS upgrades or other Operating Systems.
2. Comment by SDPringle
Nov 06, 2015
See: hg:euphoria/rev/a9e390c58a67
changeset: 6388:a9e390c58a67 branch: 4.0 user: Shawn David Pringle B.Sc. <shawn.pringle@gmail.com> date: Thu Nov 05 12:33:29 2015 -0300 files: tests/t_filesys.e description:
- added a loop in t_filesys.e to crash it while ticket 938 remains unfixed.
3. Comment by SDPringle
Nov 06, 2015
See: hg:euphoria/rev/60427109d47f
changeset: 6390:60427109d47f branch: 4.0 tag: tip user: Shawn David Pringle B.Sc. <shawn.pringle@gmail.com> date: Fri Nov 06 08:23:40 2015 -0300 files: tests/t_filesys.e description:
- test for file handle leakage in more situations in copy_file. * test for creating an empty file when source is a directory in copy_file. ticket 938
4. Comment by SDPringle
Nov 12, 2015
See: hg:euphoria/rev/85f1de9939fc
changeset: 6394:85f1de9939fc branch: 4.0 tag: tip user: Shawn David Pringle B.Sc. <shawn.pringle@gmail.com> date: Fri Nov 13 00:27:43 2015 -0300 files: include/std/filesys.e description:
- changed implementation of copy_file: fixes ticket 938
5. Comment by SDPringle
May 04, 2018
See: hg:euphoria/rev/5b8912a4a2cf
changeset: 6468:5b8912a4a2cf branch: 4.0 user: Shawn David Pringle B.Sc. <shawn.pringle@gmail.com> date: Fri May 04 10:00:59 2018 -0300 files: docs/release/4.0.6.txt description:
- updated the release notes. ticket 831, ticket 907, ticket 803, ticket 853, ticket 928, ticket 938, ticket 752, ticket 915, ticket 948, ticket 921