0x4E4F@sh.itjust.works to linuxmemes@lemmy.worldEnglish · 25 days agoTheoretical physicists: Actually...sh.itjust.worksimagemessage-square29fedilinkarrow-up1319arrow-down11
arrow-up1318arrow-down1imageTheoretical physicists: Actually...sh.itjust.works0x4E4F@sh.itjust.works to linuxmemes@lemmy.worldEnglish · 25 days agomessage-square29fedilink
minus-squareTimeSquirrel@kbin.melroy.orglinkfedilinkarrow-up2·25 days agoProgrammatically, what does the kernel actually do with data sent to /dev/null? Put it in a temp buffer and just delete it?
minus-squareBoxscape@lemmy.sdf.orglinkfedilinkarrow-up1·edit-225 days ago Programmatically, what does the kernel actually do with data sent to /dev/null? I imagine it’s like getting nullified in that olde show ReBoot.
minus-squarem_f@midwest.sociallinkfedilinkarrow-up1·25 days agoI was also curious, here’s a good answer: https://unix.stackexchange.com/questions/670199/how-is-dev-null-implemented The implementation is: static ssize_t write_null(struct file *file, const char __user *buf, size_t count, loff_t *ppos) { return count; }
minus-squareTimeSquirrel@kbin.melroy.orglinkfedilinkarrow-up1·25 days agoSo it’s basically doing nothing and lying about it. 😆
minus-squareTaldenNZ@lemmy.nzlinkfedilinkEnglisharrow-up4·25 days ago“I accepted all of the bytes you gave me. I didn’t do anything with them, but I accept you gave them to me”.
minus-squareFlipper@feddit.orglinkfedilinkarrow-up1·25 days agoThe syscall to write passes a buffer and length. If it is Dev null the call just returns without doing anything more.
Programmatically, what does the kernel actually do with data sent to /dev/null? Put it in a temp buffer and just delete it?
I imagine it’s like getting nullified in that olde show ReBoot.
I was also curious, here’s a good answer:
https://unix.stackexchange.com/questions/670199/how-is-dev-null-implemented
The implementation is:
static ssize_t write_null(struct file *file, const char __user *buf, size_t count, loff_t *ppos) { return count; }
So it’s basically doing nothing and lying about it. 😆
“I accepted all of the bytes you gave me. I didn’t do anything with them, but I accept you gave them to me”.
The syscall to write passes a buffer and length. If it is Dev null the call just returns without doing anything more.