I have a simple small app that suports cin/cout interaction. But there are times (lots of them) when I do not care about that interaction and just want to run my app in background. So I start it with command like nohup ./myServer >& /dev/null &but it eats 100% of one of my cores because nohup sends eof then endl or something like that to my app, my app thinks that this is dull user and proposes him with list of interaction commands and waits for new commad, nohup sends eof then endl again and so on recursively.So one core gets eaten up with this crappy interaction. I want to start nohup so that it would send no data at all to my app - no eof, endl, etc how to do such thing?How to make nohup send no data at all to my app after it started it?
nohup sends eof (or some other data) info my app when running recursively. How to make it stop or not send at all?
linux;nohup
The fix for that is to fix your application.nohup doesn't send anything to anyone. Your application on the other hand is assuming that stdin is a valid, open file descriptor. It should be checking the return code of whatever primitive it is using to get the data from standard input, and react accordingly if the input stream is found to be closed or invalid.Since you say cin, I'm going to assume you're coding in C++. This is a safe way of getting strings from std::cinvoid get_input(){    std::cout << getting input << std::endl;    std::string input;    while (std::cin >> input) {        // Good, got something from cin        std::cout <<  *  << input << std::endl;    }    std::cout << out of input loop << std::endl;    std::cout << std::cin.eof() << std::endl;    std::cout << std::cin.bad() << std::endl;}This is a bad way of getting user input:void bad_input(){    std::cout << getting input << std::endl;    std::string input;    while (!std::cin.bad()) {        std::cin >> input;  // BAD: not checking if the extractor succeeded        std::cout << input << std::endl;        // do stuff    }    // Not reached if `std::cin` reaches EOF    std::cout << out of input loop << std::endl;}Since a stream at eof isn't bad(), this will loop forever once cin reaches OEF. There are many variations for this (both good and bad versions), and similar problems can arise in plain C (and many other languages) for similar reasons.