Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

Recent example: mountlo (using UML):

vi@vi-notebook:~/b$ mountlo -m 16 -d /dev/uba1 /home/vi/mnt/usb -t vfat -o iocharset=utf8,allow_other&
[1] 32561
vi@vi-notebook:~/b$ Checking that ptrace can change system call numbers...OK
Checking syscall emulation patch for ptrace...OK
Checking advanced syscall emulation patch for ptrace...OK
Checking PROT_EXEC mmap in /tmp...OK
Checking for the skas3 patch in the host:
  - /proc/mm...not found
  - PTRACE_FAULTINFO...not found
  - PTRACE_LDT...not found
UML running in SKAS0 mode


[1]+  Stopped                 mountlo -m 16 -d /dev/uba1 /home/vi/mnt/usb -t vfat -o iocharset=utf8,allow_other
vi@vi-notebook:~/b$ bg
[1]+ mountlo -m 16 -d /dev/uba1 /home/vi/mnt/usb -t vfat -o iocharset=utf8,allow_other &

[1]+  Stopped                 mountlo -m 16 -d /dev/uba1 /home/vi/mnt/usb -t vfat -o iocharset=utf8,allow_other
vi@vi-notebook:~/b$ bg
[1]+ mountlo -m 16 -d /dev/uba1 /home/vi/mnt/usb -t vfat -o iocharset=utf8,allow_other &

[1]+  Stopped                 mountlo -m 16 -d /dev/uba1 /home/vi/mnt/usb -t vfat -o iocharset=utf8,allow_other
vi@vi-notebook:~/b$ bg
[1]+ mountlo -m 16 -d /dev/uba1 /home/vi/mnt/usb -t vfat -o iocharset=utf8,allow_other &

[1]+  Stopped                 mountlo -m 16 -d /dev/uba1 /home/vi/mnt/usb -t vfat -o iocharset=utf8,allow_other
vi@vi-notebook:~/b$ fg
mountlo -m 16 -d /dev/uba1 /home/vi/mnt/usb -t vfat -o iocharset=utf8,allow_other
Linux version 2.6.15 (miko@dorka) (gcc version 3.3.5 (Debian 1:3.3.5-13)) #1 Mon Feb 27 13:27:52 CET 2006
(normal output)
...

vi@vi-notebook:~/b$ socat - exec:'mountlo -m 16 -d /dev/uba1 /home/vi/mnt/usb -t vfat -o iocharset=utf8\,allow_other',pty,ctty
fusermount: waitpid: No child processes
vi@vi-notebook:~/b$ 

Also happens with Gimp (when it does run it's plug-ins). Parts of Gimp started by `gimp q.jpg&' freeze and cannot continue unless "killall -CONT" or made foreground.

Is it a bug? How to reliably start things in a background?

share|improve this question
add comment

1 Answer 1

up vote 0 down vote accepted

It's probably not a bug. Sometimes a program wants or needs to communicate with the standard input (STDIN). For example it might want to ask a question. But a program cannot do this unless it's running in the foreground, so then you get the "Stopped" notice. You can then bring it to the foreground with 'fg'. Sometimes it works to redirect standard input from some file, but then you might need to know what to put in that file. You could try redirecting from /dev/null which should always be available to the program, even if it's running in the background. To run with STDIN redirected from /dev/null, you could do:

$ program arg1 arg2 arg3 ... </dev/null

There are times when a program will insist that STDIN be a terminal, so this may not work and it might not work anyway if, the program is expecting some data . Bottom line, some programs expect to work in an interactive manner and will not work properly when backgrounded.

share|improve this answer
    
Yes, it interacts with STDIN. Cannot yet implement a workaround to make it work right. yes "" | mountlo .... is the closest. –  Vi. May 23 '10 at 15:52
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.