Mktempdir() should provide scope to declare a prefix

Hi All,

I think it may help if mktempdir() can provide an option of a prefix very similar to you can do with mkdtemp in posix. This provides the module developers to create temp directories with their own prefix which can help them able to track the directories created by them than everything starting with tmp or jl_ prefix.

regards,

Sambit

You can already do that by providing the parent directory.

@yuyichao

While providing a parent directory is a workaround, a third party application or user can technically create the same directory and assign it a non-rwx access control for the Julia process. This can lead to a denial of service on a multi-user system. Ideally, mktempdir() should never fail unless there is no hard disk or user has a quota restriction etc. not the directory is existing.

If the tmp parent has to be a random directory with mktempdir() the module may need to persist the value in between sessions which may unnecessarily increase housekeeping. Hence, prefix for mktempdir() has some intrinsic benefits.

regards,

Sambit

I agree with you that adding a prefix can be useful. It turns out a pull request has been opened more than a year ago to support custom suffixes, but it was closed because the Windows API doesn’t support them. It does support prefixes though (but it only uses up to three characters). So we could keep "tmp" as the default prefix, but allow changing it to anything else.

Could you file an issue? If you feel like it, you could take inspiration from that old pull request to implement support for custom prefixes.

Issue created: https://github.com/JuliaLang/julia/issues/22922

1 Like