which signal will flush the file buffer and then exit in C/C++ ? eg. send a signal to flush all file buffers to files/stdout with out invoking fflush(). -INT, -TERM? How do OS or runtime library handle these signals by default? someone help me, thanks in advance! waiting online...
no, i mean how OS handle a signal by default before killing a process. I don't mean I'll write a program like this. What if you have only the executable server file? You run the file, somehow want to stop the process later, and parse the log. If all the file buffers are not flushed before the process is killed. you may lose some important log. Right, so I wander whether the OS's default handler of some signal will do this.
No, it's not possible. A kill will have the effect you want to avoid; you will lose the latest log stuff cos it'll still be buffered. You cannot force a process to quit via a normal exit; any forced quit is by definition an abnormal exit. The only way you can make a process exit normally is to send it commands to exit, which by definition are process-dependent, so you will need the source code, or at least the assistance of the program's developers.