I am running a long linux program in a remote machine, and I want to stop it, but my problem is that if I use the kill command then the program will exit without saving resu
If you control the long-running remote process, you could install a signal handler for SIGTERM (see man signal and man sigaction and the many SO questions on this topic), to cleanup nicely before dieing.