I wrote this shell script to exemplify the bullet points below: #! /usr/bin/env bash
space() { df -h / echo } echo Space before creating large file: space echo Creating large file: dd if=/dev/zero of=large_file bs=1G count=10 echo echo Space after creating large file: space echo Opening large file in background process: bash -c 'exec 3< large_file; sleep 10; echo Closing large file' & pid=$! echo echo Removing large file: sleep 1; rm -v large_file echo echo Space after removing large file: space echo Waiting for large file closure: wait "$pid" echo echo Space after closing large file: space Which confirms expectations: Space before creating large file: Filesystem Size Used Avail Capacity iused ifree %iused Mounted on /dev/disk3s3s1 228Gi 10Gi 188Gi 6% 425k 2.0G 0% / Creating large file: 10+0 records in 10+0 records out 10737418240 bytes transferred in 5.169940 secs (2076894169 bytes/sec) Space after creating large file: Filesystem Size Used Avail Capacity iused ifree %iused Mounted on /dev/disk3s3s1 228Gi 10Gi 178Gi 6% 425k 1.9G 0% / Opening large file in background process: Removing large file: large_file Space after removing large file: Filesystem Size Used Avail Capacity iused ifree %iused Mounted on /dev/disk3s3s1 228Gi 10Gi 178Gi 6% 425k 1.9G 0% / Waiting for large file closure: Closing large file Space after closing large file: Filesystem Size Used Avail Capacity iused ifree %iused Mounted on /dev/disk3s3s1 228Gi 10Gi 188Gi 6% 425k 2.0G 0% / > On 8 Dec 2021, at 09:13, Brian Candler <b.cand...@pobox.com> wrote: > > As a general request, please don't post screen images. They are very hard to > read, especially for (but not exclusively for) those with visual impairment. > They also can't be copy-pasted. > > You haven't said what platform you are running on. However if this is Linux > or another POSIX-compatible system, it's perfectly fine to delete a file > while it's open. The file remains on disk until the last process which has > an open file handle has closed it. > > You can demonstrate this quite easily: > - create a large (multi-gigabyte) file > - check the filesystem free space > - open the file > - delete it > - check the filesystem free space > - close it > - check the filesystem free space > > Only after closing the file will the free space be returned to the filesystem. > > -- > You received this message because you are subscribed to the Google Groups > "golang-nuts" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to golang-nuts+unsubscr...@googlegroups.com > <mailto:golang-nuts+unsubscr...@googlegroups.com>. > To view this discussion on the web visit > https://groups.google.com/d/msgid/golang-nuts/db180a5a-71f3-4328-a50b-cea0f85bd174n%40googlegroups.com > > <https://groups.google.com/d/msgid/golang-nuts/db180a5a-71f3-4328-a50b-cea0f85bd174n%40googlegroups.com?utm_medium=email&utm_source=footer>. -- You received this message because you are subscribed to the Google Groups "golang-nuts" group. To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscr...@googlegroups.com. To view this discussion visit https://groups.google.com/d/msgid/golang-nuts/E0B99047-2AEC-47DA-A2D5-2D95B8FD9001%40gmail.com.