One of the most important things you need to know about Linux (or Unix) systems is just the file. Since you are just reading from /proc/loadavg
, the easiest way to accomplish what you need is to simply create a text file containing the line of text that you will see when you run cat /proc/loadavg
. Then ask your program to read from this file, which you created instead of /proc/loadavg
, and it will not be wiser. If you want to test in different "artificial" situations, just change the text in this file and save. When your testing is complete, just change your reading program from /proc/loadavg
and you can be sure that it will work as expected.
Note that you can make this text file anywhere ... in your home directory, in the program directory, anywhere. However, you should not do this in /proc
. This directory is reserved for system objects.
source share