# US 2024/0394058 A1 · Enhanced techniques for avoiding double closures of file descriptors

> Agents: this data is available as JSON from the patentgrep API and MCP server — see https://patentgrep.com/llms.txt

- Number: US 2024/0394058 A1
- Document ID: US20240394058A1
- Status: Published application
- Kind: A1
- Application number: 18/442,008
- Filed: 2024-02-14
- Published: 2024-11-28
- Earliest claimed: 2023-05-26
- Assignees: Sandpiper CDN, LLC
- Applicants: Sandpiper CDN, LLC
- Inventors: William CROWDER
- Web page: https://patentgrep.com/patent/US20240394058A1

## CPC

- G06F 9/3005: {to perform operations for flow control}
- G06F 9/545: {where tasks reside in different layers, e.g. user- and kernel-space}
- G06F 16/162: {Delete operations (erasing in storage systems G06F3/0652)}
- G06F 16/1774: {Locking methods, e.g. locking methods for file systems allowing shared and concurrent access to files}
- G06F: ELECTRIC DIGITAL DATA PROCESSING (computer systems based on specific computational models G06N)

## Abstract

This disclosure describes systems, methods, and devices related to preventing multiple closures of a file descriptor. A method may include identifying a close( ) system call requesting closure of a file descriptor that is opened to a first file; generating, based on the close( ) system call, prior to closing the file descriptor, a dup2( ) system call for the file descriptor; releasing, based on the dup2( ) system call, the first file from the file descriptor; opening, based on the dup2( ) system call, the file descriptor to a second file; determining that a threshold delay from receipt of the close( ) system call has expired; and closing, based on the expiration of the threshold delay, the file descriptor.

## Claims

### Claim 1

A method of preventing multiple closures of a file descriptor, the method comprising:
identifying, by at least one processor of a device, a close( ) system call requesting closure of a file descriptor that is opened to a first file;
generating, by the at least one processor, based on the close( ) system call, prior to closing the file descriptor, a dup2( ) system call for the file descriptor;
releasing, by the at least one processor, based on the dup2( ) system call, the first file from the file descriptor;
opening, by the at least one processor, based on the dup2( ) system call, the file descriptor to a second file;
determining, by the at least one processor, that a threshold delay from receipt of the close( ) system call has expired; and
closing, by the at least one processor, based on the expiration of the threshold delay, the file descriptor.

### Claim 2 (depends on 1)

The method of claim 1, wherein the threshold delay is a threshold amount of time.

### Claim 3 (depends on 1)

The method of claim 1, wherein the threshold delay is a number of dup2( ) system calls generated in response to close( ) system calls.

### Claim 4 (depends on 3)

The method of claim 3, further comprising:
receiving a second close( ) system call requesting closure of a second file descriptor;
generating, based on the second close( ) system call, prior to closing the second file descriptor, a second dup2( ) system call for the second file descriptor;
wherein determining that the threshold delay from the receipt of the close( ) system call has expired comprises determining that a sum of dup2( ) system calls, comprising the dup2( ) system call and the second dup2( ) system call, exceeds the threshold delay.

### Claim 5 (depends on 1)

The method of claim 1, wherein the file is a /dev/null file.

### Claim 6 (depends on 1)

The method of claim 1, wherein the threshold delay is proportional to a rate at which new file descriptors are required and a number of supported file descriptors comprising the file descriptor.

### Claim 7 (depends on 1)

The method of claim 1, further comprising:
determining that the file descriptor is the least-recently-used file descriptor among recently-used file descriptors that have been duplicated using dup2( ) system calls,
wherein closing the file descriptor is further based on the file descriptor being the least-recently-used file descriptor.

### Claim 8

A device for preventing multiple closures of a file descriptor, the device comprising memory coupled to at least one processor, wherein the at least one processor is configured to:
identify a close( ) system call requesting closure of a file descriptor that is opened to a first file;
generate, based on the close( ) system call, prior to closing the file descriptor, a dup2( ) system call for the file descriptor;
release, based on the dup2( ) system call, the first file from the file descriptor;
open, by the at least one processor, based on the dup2( ) system call, the file descriptor to a second file;
determine, by the at least one processor, that a threshold delay from receipt of the close( ) system call has expired; and
close, by the at least one processor, based on the expiration of the threshold delay, the file descriptor.

### Claim 9 (depends on 8)

The device of claim 8, wherein the threshold delay is a threshold amount of time.

### Claim 10 (depends on 8)

The device of claim 8, wherein the threshold delay is a number of dup2( ) system calls generated in response to close( ) system calls.

### Claim 11 (depends on 10)

The device of claim 10, wherein the at least one processor is further configured to:
receive a second close( ) system call requesting closure of a second file descriptor;
generate, based on the second close( ) system call, prior to closing the second file descriptor, a second dup2( ) system call for the second file descriptor;
wherein to determine that the threshold delay from the receipt of the close( ) system call has expired comprises to determine that a sum of dup2( ) system calls, comprising the dup2( ) system call and the second dup2( ) system call, exceeds the threshold delay.

### Claim 12 (depends on 8)

The device of claim 8, wherein the file is a /dev/null file.

### Claim 13 (depends on 8)

The device of claim 8, wherein the threshold delay is proportional to a rate at which new file descriptors are required and a number of supported file descriptors comprising the file descriptor.

### Claim 14 (depends on 8)

The device of claim 8, wherein the at least one processor is further configured to:
determine that the file descriptor is the least-recently-used file descriptor among recently-used file descriptors that have been duplicated using dup2( ) system calls, wherein to close the file descriptor is further based on the file descriptor being the least-recently-used file descriptor.

### Claim 15

A system for preventing multiple closures of a file descriptor, the system comprising:
at least one processor coupled to memory, the at least one processor configured to:
identify a close( ) system call requesting closure of a file descriptor that is opened to a first file;
generate, based on the close( ) system call, prior to closing the file descriptor, a dup2( ) system call for the file descriptor;
release, based on the dup2( ) system call, the first file from the file descriptor;
open, by the at least one processor, based on the dup2( ) system call, the file descriptor to a second file;
determine, by the at least one processor, that a threshold delay from receipt of the close( ) system call has expired; and
close, by the at least one processor, based on the expiration of the threshold delay, the file descriptor.

### Claim 16 (depends on 15)

The system of claim 15, wherein the threshold delay is a threshold amount of time.

### Claim 17 (depends on 15)

The system of claim 15, wherein the threshold delay is a number of dup2( ) system calls generated in response to close( ) system calls.

### Claim 18 (depends on 17)

The system of claim 17, wherein the at least one processor is further configured to:
receive a second close( ) system call requesting closure of a second file descriptor;
generate, based on the second close( ) system call, prior to closing the second file descriptor, a second dup2( ) system call for the second file descriptor;
wherein to determine that the threshold delay from the receipt of the close( ) system call has expired comprises to determine that a sum of dup2( ) system calls, comprising the dup2( ) system call and the second dup2( ) system call, exceeds the threshold delay.

### Claim 19 (depends on 15)

The system of claim 15, wherein the file is a/dev/null file.

### Claim 20 (depends on 15)

The system of claim 15, wherein the threshold delay is proportional to a rate at which new file descriptors are required and a number of supported file descriptors comprising the file descriptor.
