Just for fun:
Is there a way to monitor/capture/dump whatever is being written to /dev/null?
On Debian, or FreeBSD, if it matters, any other OS specific solutions are also welcome.
|
Just for fun: On Debian, or FreeBSD, if it matters, any other OS specific solutions are also welcome. |
|||||||||
|
|
Making
This should work under all Linux distributions, and all major BSDs. |
|||||||||||||||||||
|
|
I think of an idea where /dev/null can be a symlink to a file descriptor but with add code mechanism to determine the operation is read or write and then if it is read, it should actually read from /dev/actualnull created seperately with mknod and if it is write then make a note of the invoking program and attempt to log/count for analyzing the programs that use /dev/null for writing. This is going to cost a lot in terms of performance, I suppose though. I guess it is not practical since most shell programs or code use redirection anyway. May be inotify could be used to monitor the usage of /dev/null ? or rewrite the kernel code that handles 1:3 devices, again compile and reinstall, experimentable. |
|||||||||
|
|
I once found out the hard way that /dev/null doesn't have to be a special dev file. A long time ago the /dev/null on an Ultrix system at work got deleted, so the next time a program redirected to /dev/null, it ended up being a normal file full of the output from that program. (I think it was 'no such file or directory', which meant when we were trying to figure out what was going on, we'd do So my suggestion would to be replace it with a named pipe, and then attach a program to the pipe that would read it and monitor it. |
|||||||||
|