I want to write a C program that will sample something every second (an extension to screen
). I can't do it in a loop since screen
waits for the program to terminate every time, and I have to access the previous sample in every execution. Is saving the value in a file really my best bet?
views:
43answers:
2
+1
A:
Is saving the value in a file really my best bet?
Unless you want to write some complicated client/server model communicating with another instance of the program just for the heck of it. Reading and writing a file is the preferred method.
Oskar N.
2010-09-06 22:05:12
+1
A:
You could use a named pipe (if available), which might allow the data to remain "in flight", i.e. not actually hit disk. Still, the code isn't any simpler, and hitting disk twice a second won't break the bank.
You could also use a named shared memory region (again, if available). That might result in simpler code.
You're losing some portability either way.
Steve Jessop
2010-09-06 22:24:17