Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

I have an application that runs fine, with and without '&' when run directly from the terminal. However, if I try to execute it from a shell script, it works only if the trailing '&' is skipped. Thus, I am unable to start this process in background from inside the shell script.

<Path to My application> <options> &

The application window opens but makes no progress after that.

(The application is a modified(by me) version of qemu 0.13.0. When I run a disk image from that in background in a shell script, I get stuck with a black screen)

share|improve this question
    
the application name would help –  hbdgaf Apr 15 '12 at 18:51
    
@aking Its a version of qemu modified by me. –  AnkurVj Apr 15 '12 at 18:53
    
okay, does stock qemu work? –  hbdgaf Apr 15 '12 at 18:54
    
@aking Yes, it does... –  AnkurVj Apr 15 '12 at 18:55

2 Answers 2

up vote 3 down vote accepted

There's no need to background the application with the ampersand when it has a built-in option for doing so. Such is the case with qemu (unless you've removed it):

% qemu-kvm --help | grep daemon
-daemonize      daemonize QEMU after initializing
share|improve this answer

Do you see a message like

[1] suspended (tty output) myapplication

in the terminal? This message means that your program is trying to read from the terminal (probably because it's reading from its standard input). Since only a foreground program can read from the terminal, the program is suspended.

If you see this message, figure out why your program is reading. In desperation, try redirecting its standard input (myapplication </dev/null).

If you see no such message, it's some other bug in your program. Look at what your program is doing in a debugger or with strace.

share|improve this answer

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.