This is especially nasty on linux, where inotify(7) events for write(2) and truncate(2)/ftruncate(2) both result in an IN_MODIFY.
To make it worse, open(2) with O_TRUNC doesn’t result in IN_MODIFY, but only IN_OPEN events and there is no way to distinguish between O_RDONLY, O_WRONLY and/or O_RDWR.
At the time tail receives and handles the events and uses stat(2) to try to detect truncations the file could have already grown to the size before the truncation or larger and there is no way to tell if the file was truncated at all.
As described, I first wondered if tail -F would do the trick, but at some point, I decided whatever code was truncating the logs needs to be killed with fire.
This is not a fair characterization of the lightning talk, imo. The whole talk centers around his frustration with dealing with an edge case of tail. At the end basically gives up and says that some kid will be complaining the same way about his own decisions and he’s so frustrated he doesn’t care, mostly as a result of wrestling with this intractable problem.
There are a number of “JESUS CHRIST ARE YOU SERIOUS?!?!” remarks shouted though, which, to me, basically just seem like a slightly nicer way of saying “JESUS CHRIST WERE THESE PEOPLE STUPID?!?!”
I didn’t watch the last minute or so as I thought the entire thing was obnoxious as hell. I tried watching it again after your comment – just to make sure I wasn’t in some particularly grouchy mood yesterday evening and mistook his remarks – and found it even more obnoxious.
To be honest, I went into the talk wanting to disagree with you and be upset with your original characterization of it.
But yeah, your criticisms are fair.
It sounds like the commenter was expecting unix to be plan 9. Unix wasn’t plan 9, nor was BSD. It’s entirely reasonable for tail’s manpage to say “it sits there waiting in hopes that the file will grow.”
I had a vivid moment recently when I realized this kind of humor just doesn’t translate very well: I was banned from contributing to homebrew for mocking what I perceived to be a poor design decision.
That’s precisely the point. Many engineers aren’t funny when they think they’re being funny. It’s obnoxious and unprofessional. Mocking others’ work also implies you’re weak: the people who do great work know how hard it is to get every aspect correct.
Either you believe that there is humor in that issue thread, or you believe I unironically prayed to the gods of hacking for a mercifully short OS update. Possibly while sacrificing a terminal session to earn their favor.
I saw it more as someone being confronted with a problem, saying “I’ll just X”, and then discovering many ways in which, in fact, just X wasn’t enough.
#ifdef APPLE y’know truncating an mmap’d file actually leads to a lot of undefined behavior
… file can be truncated overwritten before tail can actually read it …
Yeah, at the outset it sounded like the user was expecting too much from tail -f and it did not sound like an OS bug to me. Regardless of the BSD manpage.
This is especially nasty on linux, where
inotify(7)
events forwrite(2)
andtruncate(2)
/ftruncate(2)
both result in anIN_MODIFY
. To make it worse,open(2)
withO_TRUNC
doesn’t result inIN_MODIFY
, but onlyIN_OPEN
events and there is no way to distinguish betweenO_RDONLY
,O_WRONLY
and/orO_RDWR
.At the time tail receives and handles the events and uses
stat(2)
to try to detect truncations the file could have already grown to the size before the truncation or larger and there is no way to tell if the file was truncated at all.As described, I first wondered if
tail -F
would do the trick, but at some point, I decided whatever code was truncating the logs needs to be killed with fire.There’s a number of rotation approaches that keep the log file in place and truncate and it’s hard to avoid them.
I missed this, I am training an ML model on Cantrill rants.
I would love to see this!
Just another example of the “every programmer before be was stupid and wrong” attitude.
What a silly rant. People pay to watch talks like this 🙄
This is not a fair characterization of the lightning talk, imo. The whole talk centers around his frustration with dealing with an edge case of
tail
. At the end basically gives up and says that some kid will be complaining the same way about his own decisions and he’s so frustrated he doesn’t care, mostly as a result of wrestling with this intractable problem.The problem was pretty interesting, too!
There are a number of “JESUS CHRIST ARE YOU SERIOUS?!?!” remarks shouted though, which, to me, basically just seem like a slightly nicer way of saying “JESUS CHRIST WERE THESE PEOPLE STUPID?!?!”
I didn’t watch the last minute or so as I thought the entire thing was obnoxious as hell. I tried watching it again after your comment – just to make sure I wasn’t in some particularly grouchy mood yesterday evening and mistook his remarks – and found it even more obnoxious.
Last minute was the most spicy part ;).
It’s just his sense of humour.
To be honest, I went into the talk wanting to disagree with you and be upset with your original characterization of it.
But yeah, your criticisms are fair.
It sounds like the commenter was expecting unix to be plan 9. Unix wasn’t plan 9, nor was BSD. It’s entirely reasonable for
tail
’s manpage to say “it sits there waiting in hopes that the file will grow.”I had a vivid moment recently when I realized this kind of humor just doesn’t translate very well: I was banned from contributing to homebrew for mocking what I perceived to be a poor design decision.
https://github.com/Homebrew/brew/issues/6154
Boop! Banned for life. No appeal, no one cared. And to be honest, I guess it was fair.
Now I wish I’d done a lightning talk on Homebrew forcing devs to upgrade their entire OS with no workaround.
Cantrill’s talk has humor, didn’t find any in your homebrew issue.
That’s precisely the point. Many engineers aren’t funny when they think they’re being funny. It’s obnoxious and unprofessional. Mocking others’ work also implies you’re weak: the people who do great work know how hard it is to get every aspect correct.
Either you believe that there is humor in that issue thread, or you believe I unironically prayed to the gods of hacking for a mercifully short OS update. Possibly while sacrificing a terminal session to earn their favor.
Oh, I can agree with the exclamations being obnoxious!
I saw it more as someone being confronted with a problem, saying “I’ll just X”, and then discovering many ways in which, in fact, just X wasn’t enough.
Yeah, at the outset it sounded like the user was expecting too much from
tail -f
and it did not sound like an OS bug to me. Regardless of the BSD manpage.