Thread: Socket Error or nohup error ??

  1. #1
    Registered User
    Join Date
    Jan 2010
    Posts
    1

    Lightbulb Socket Error or nohup error ??

    Hi friends,
    1. I have created a client socket to receive a data from the server.
    2. The data received from the server will be shown in the terminal.
    3. i want to run this application as a background and i want to redirect the output to a file. and also i want to run this application even when i log out so i did as given below

    nohup myprogram > foo.out 2> foo.err < /dev/null &

    4. when i use
    $tailf foo.out

    Everything is fine. I can view the output

    but
    i cannot able to view the last data i received.

    5. If i run that on terminal, everything is fine. i can able to see the data, even the last one i received.

    If i run the same using nohup, i could not able to view the last received data.
    Can any one help me out to solve this problem

    Thanks in advance

  2. #2
    Registered User
    Join Date
    Jul 2007
    Posts
    131
    Do you flush output after printing?

  3. #3
    Registered User jeffcobb's Avatar
    Join Date
    Dec 2009
    Location
    Henderson, NV
    Posts
    875
    A cheat would be to use the screen tool...basically run a screen session in a terminal, start your app as if you were running in a terminal and then hit Ctrl-a d (detach session). Then you can log out. When you log into the box again, just run screen -r <reattach to session>; it should auto-attach to the previous session. Note that screen has a lot of powerful tools to offer; see man page...
    C/C++ Environment: GNU CC/Emacs
    Make system: CMake
    Debuggers: Valgrind/GDB

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. An error is driving me nuts!
    By ulillillia in forum C Programming
    Replies: 5
    Last Post: 04-04-2009, 09:15 PM
  2. Testing some code, lots of errors...
    By Sparrowhawk in forum C Programming
    Replies: 48
    Last Post: 12-15-2008, 04:09 AM
  3. Post...
    By maxorator in forum C++ Programming
    Replies: 12
    Last Post: 10-11-2005, 08:39 AM
  4. Why wont my function exit correctly?
    By LightsOut06 in forum C Programming
    Replies: 2
    Last Post: 10-09-2005, 09:23 PM
  5. ras.h errors
    By Trent_Easton in forum Windows Programming
    Replies: 8
    Last Post: 07-15-2005, 10:52 PM