Describe how mkstemp(3) is able to create and open a new ?le (one that doesn’t yet exist) without creating a timing window that allows another process to create the ?le between the time that mkstemp decides on a name and the time that it creates the ?le.
What will be an ideal response?
The mkstemp function selects a random string for use in the caller’s template, then calls open(2) with the name based on the randomized string and the open ?ags set to O_RDWR|O_CREAT|O_EXCL.Ifthe ?le exists, then the open will fail because of the O_EXCL ?ag. Then mkstemp will try a new name. Otherwise, the ?le is created atomically because of the combination of the O_CREATandO_EXCL?ags
Computer Science & Information Technology
You might also like to view...
Observe how a DHCP client renews a lease and saves the captured traffic to a file. What type of DHCP message can be observed?
What will be an ideal response?
Computer Science & Information Technology
What is a professional association and which services does it provide to its members?
What will be an ideal response?
Computer Science & Information Technology