Open Whiletru3 opened 2 years ago
Tagging subscribers to this area: @mangod9 See info in area-owners.md if you want to be subscribed.
Author: | Whiletru3 |
---|---|
Assignees: | - |
Labels: | `area-System.Threading`, `untriaged` |
Milestone: | - |
Good catch. This is because on Unix, forward slash is not valid in a file name. Here's the check:
Do you want to update the docs? As well as Mutex, EventWaitHandle and Semaphore also can be named and those names are subject to this restriction.
To update the docs, you can click the "edit" button (a pencil) at the top of the topic. Or provide a PR against the dotnet/dotnet-api-docs repo.
I'm going to move this issue to that repo, either way.
Description
I try to use System.Threading Mutex(bool initiallyOwned, string? name, out bool createdNew) on macOS in a net6 project. The name I use contain a slash ("/"). On windows I have no issue with it, but on macOS, I have an exception :
There are no such of restriction in the documentation, only the backslash is reserved.
https://docs.microsoft.com/en-us/dotnet/api/system.threading.mutex?view=net-6.0
The backslash (\) is a reserved character in a mutex name. Don't use a backslash (\) in a mutex name except as specified in the note on using mutexes in terminal server sessions. Otherwise, a [DirectoryNotFoundException](https://docs.microsoft.com/en-us/dotnet/api/system.io.directorynotfoundexception?view=net-6.0) may be thrown, even though the name of the mutex represents an existing file.
It could be good to add the / as reserved.
Reproduction Steps
Mutex mutex = new Mutex(true, "1234/5678", out var isCreatedNew);
Expected behavior
no exception or invalid name
Actual behavior
launch an exception
Regression?
No response
Known Workarounds
replace / with another character
Configuration
.net6 Mac 12.3 x64
Other information
No response