What does “program &” mean on the command line?

后端 未结 2 1401
感情败类
感情败类 2021-01-29 14:40

I need to develop a client and server program with using sockets. My program should get port number from the command line. I saw an example which says \"myprogram 2454 &\".<

相关标签:
2条回答
  • 2021-01-29 14:57

    The ampersand (&) means that you want to run myprogram in background. This is normally used when you want to stay on your command-prompt and continue the work on the same session.

    Example

    somescript  &
    

    will run the somescript shell script in background. You will get the prompt back on the next line. If you run somescript without & then the prompt may not appear back because somescript may take more time.

    The best way is to run it in background with no hangups, in which case even of you loose your connection to the host the process keeps running on the UNIX or Linux host.

    For example

    nohup  somescript &
    

    the jobs command will display the jobs running in background.

    0 讨论(0)
  • 2021-01-29 14:59

    It means to start the process in the background. http://tldp.org/LDP/abs/html/x9644.html so that you may continue to use your shell session to run other programs. You can then use fg to "foreground" your process again.

    0 讨论(0)
提交回复
热议问题