Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I need to daemonize a Windows app running in Wine, and create a pid in /var/run. Since it requires an X11 session to run, I need to make sure the $DISPLAY variable is set in the running user's environment.

Assuming I already have a X11 session running, with a given display, here's what the start-stop-daemon line looks like in my /etc/init.d script:

start-stop-daemon --start --pidfile /var/run/ -m -c myuser -g mygroup -k 002 --exec /home/myuser/.wine/drive_c/Program\ Files/wine-app.exe

Unfortunately, my version of start-stop-daemon on Ubuntu 8.04 doesn't have the -e option to set environmental variables. I gather that you could simply set $DISPLAY before the command, like so:

VAR1="Value" start-stop-daemon ...

But it doesn't work. Since I'm using the -c {user} option to run as a specific user, I'm guessing there's an environment switch and VAR1 is lost. I've tried exporting DISPLAY from the running user's .profile and/or .bashrc but it doesn't work either.

Is there another way to do this? Is this even possible? Am I overlooking something?

share|improve this question
up vote 2 down vote accepted

You could write a shell script to set the variable and then run wine.

share|improve this answer
Haven't had the chance to put this in to practice, but I wrote the script and it seems like the best way to go. Thanks for the tip! – scottburton11 Apr 9 '10 at 21:07

You can use env to modify the environment:

start-stop-daemon --start --pidfile /var/run/ -m -c myuser -g mygroup -k 002 --exec /usr/bin/env VAR1="Value" /home/myuser/.wine/drive_c/Program\ Files/wine-app.exe
share|improve this answer

Your Answer


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.