LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   Stdin,stdout,stderr wehn to run mplayer in background (https://www.linuxquestions.org/questions/linux-newbie-8/stdin-stdout-stderr-wehn-to-run-mplayer-in-background-4175638947/)

luofeiyu 09-22-2018 03:18 AM

Stdin,stdout,stderr wehn to run mplayer in background
 
Run mplayer in background with no stdin,no stdout,no stderr.
Code:

    ~$  mplayer fly.mp3 0</dev/null 1>/dev/null 2>&1 &
It can be simplied as
Code:

    ~$  mplayer fly.mp3 </dev/null >/dev/null 2>&1 &
1.Run mplayer in background with no stdin.
Code:

    ~$  mplayer fly.mp3 </dev/null  &
`ctrl+c` can't kill the playing ,it means that `Run mplayer in background with no stdin` take effect.


2.Run mplayer in background with no stdout.
Code:

    ~$  mplayer fly.mp3  1>/dev/null  &
    [1] 8561
    jobs
    [1]+  Stopped                mplayer fly.mp3 > /dev/null

`mplayer fly.mp3 0</dev/null 1>/dev/null 2>&1 &` can run mplayer in background with no stdin ,no stdout ,no stderr,
why `mplayer fly.mp3 1>/dev/null &` can not run mplayer in background with no stdout?

3.Run mplayer in background with no stderror.
Code:

    ~$  mplayer fly.mp3  2>/dev/null  &
    [1] 6874
    ~$ MPlayer 1.3.0 (Debian), built with gcc-6.2.1 (C) 2000-2016 MPlayer Team

Why no voice?

business_kid 09-22-2018 10:44 AM

what happens with '$ mplayer fly.mp3' or 'mpg123 fly.mp3'?

lougavulin 09-22-2018 11:22 AM

mplayer does read on stdin and write on both stdout and stderr. To send it in background you have to redirect its stdin.
Your commands redirecting only stdout or sdterr don't work because it halts waiting a stdin. As you saw if you redirect only stdin it works.


All times are GMT -5. The time now is 09:47 PM.