3 ms·
> Turns out, that if you use a Unix socket and the filename starts with a null byte, like \0foo the socket will not exist on the filesystem and it’ll be automat
by ambicapter 2y ago
> Turns out, that if you use a Unix socket and the filename starts with a null byte, like \0foo the socket will not exist on the filesystem and it’ll be automatically removed when no longer used. Weird! Cool!
Is that…intentional on Unix’s part? Seems kind of a weird thing to implement.
- spc476 2y agoI believe that's a Linux thing.
- o11c 2y agoIt's very useful since "how do I atomically delete a stale socket file" is not actually an easy thing to do.
- deleted 2y ago[deleted]
- somat 2y agofiles on unix are referenced counted. and unix sockets are just a type of file. every link adds to the count, a link can be a filesystem name but open file handles are also links. once there are no more links to a file the file can be deleted. so this is opening a unix socket with a no name(the initial null terminates the C style string) thus leaving the only link to it as the file discripter. One trick I used to do was to sneak another link to the file to keep it around before the process ended , The serious real use case for this was if you had accidentally deleted a file but some process was keeping it open somewhere, but I mainly used it back when youtube was flash based it would try and keep the video cache file hidden this way. and you could make a copy of the video by snaging the correct file descriptor.
- jumploops 2y agoI have fond memories of modifying the memory of flash-based games when they first launched on Facebook. I don't remember the FB account credentials, but I received thousands of messages from people either telling me I was a terrible person, or trying to bribe me so they could beat their sibling... all for a simple helicopter game. Fun times.
- 9dev 2y agoThat sounds like a bug in the spec rather than an intentional feature, though?