LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices


Reply
  Search this Thread
Old 05-18-2011, 09:59 AM   #1
kopatops
Member
 
Registered: Mar 2010
Distribution: Arch Linux
Posts: 45
Blog Entries: 1

Rep: Reputation: 16
Question Does anyone know of a daemon that in essence "does nothing"?


I couldn't find it googling.

I think I want a daemon that does nothing but keep this bash script, (specified in the ~/.xinitrc exec line) alive:

(What I would like is written in bold)

Code:
LIBGL_ALWAYS_INDIRECT=1
INTEL_BATCH=1

#pcmanfm --desktop &
nautilus --no-default-window &
stalonetray &
#xfce4-panel &
python2 /usr/share/screenlets-manager/screenlets-daemon.py &
python2 /usr/share/screenlets/ACPIBattery/ACPIBatteryScreenlet.py &
pidgin &
compiz --use-root-window --indirect-rendering ccp &
daemon-that-uses-no-resources
#fluxbox
I used to have my X session die with the Compiz process, but now I need to execute some things after Compiz in the script above, meaning I have to background it.

I figure, anyhow, it makes sense to have the life of ~/.xinitrc depend on a process that isn't used for anything else (?).
 
Click here to see the post LQ members have rated as the most helpful post in this thread.
Old 05-18-2011, 10:06 AM   #2
business_kid
LQ Guru
 
Registered: Jan 2006
Location: Ireland
Distribution: Slackware, Slarm64 & Android
Posts: 16,260

Rep: Reputation: 2321Reputation: 2321Reputation: 2321Reputation: 2321Reputation: 2321Reputation: 2321Reputation: 2321Reputation: 2321Reputation: 2321Reputation: 2321Reputation: 2321
inetd with all services disabled :-))? There are options to inetd to allow it to use a command line specified config file.
 
0 members found this post helpful.
Old 05-18-2011, 10:28 AM   #3
segmentation_fault
Member
 
Registered: Sep 2008
Location: Ioannina, Greece
Distribution: Gentoo
Posts: 332

Rep: Reputation: 55
Why don't you try to write a program or script that sleeps for eternity?

If I got it right, you want your xsession to die by another program, and not the compiz (I've never used compiz, so I'm not quit shure for what I say). Have you tried to add at the end of .xinitrc "exec xterm" ?
then the session will be terminated by closing that xterm (or any other program put there).

Last edited by segmentation_fault; 05-18-2011 at 10:35 AM.
 
Old 05-18-2011, 11:10 AM   #4
kopatops
Member
 
Registered: Mar 2010
Distribution: Arch Linux
Posts: 45

Original Poster
Blog Entries: 1

Rep: Reputation: 16
(Pardon the delayed response)

Quote:
Originally Posted by segmentation_fault View Post
Why don't you try to write a program or script that sleeps for eternity?

If I got it right, you want your xsession to die by another program, and not the compiz (I've never used compiz, so I'm not quit shure for what I say). Have you tried to add at the end of .xinitrc "exec xterm" ?
then the session will be terminated by closing that xterm (or any other program put there).
My exec line in .xinitrc (only 1 is allowed) invokes the script (~/bin/mo-de) in the original post, which serves as my desktop environment. This means that when mo-de ends, the xinitrc script ends, and my x-session ends.

Quote:
Originally Posted by segmentation_fault View Post
Why don't you try to write a program or script that sleeps for eternity?
Exactly what I would like! But I don't know how to do this.

Code:
NAME
       sleep - delay for a specified amount of time

SYNOPSIS
       sleep NUMBER[SUFFIX]...
       sleep OPTION

DESCRIPTION
       Pause  for  NUMBER seconds.  SUFFIX may be `s' for seconds (the default), `m' for minutes,
       `h' for hours or `d' for days.  Unlike most implementations  that  require  NUMBER  be  an
       integer,  here  NUMBER may be an arbitrary floating point number.  Given two or more argu‐
       ments, pause for the amount of time specified by the sum of their values.
sleep doesn't accept "∞" as argument. :P

Quote:
Originally Posted by segmentation_fault View Post
Have you tried to add at the end of .xinitrc "exec xterm" ?.
Indeed, I could replace daemon-that-uses-no-resources with xterm. But xterm would run as a window in my DE; I need a background process, something that doesn't get in my way "graphically".

EDIT: Maybe I was out of my mind writing "daemon"! That is probably not what I need.
I need something that stays attached to the script (~/bin/mo-de), keeping it alive.

Sorry for being difficult/ignorant :P
Thank you for the answers so far.

Last edited by kopatops; 05-18-2011 at 11:24 AM. Reason: I screwed up!
 
Old 05-18-2011, 02:55 PM   #5
MTK358
LQ 5k Club
 
Registered: Sep 2009
Posts: 6,443
Blog Entries: 3

Rep: Reputation: 723Reputation: 723Reputation: 723Reputation: 723Reputation: 723Reputation: 723Reputation: 723
Quote:
Originally Posted by kopatops View Post
sleep doesn't accept "∞" as argument. :P
No problem:

Code:
while true; do sleep 60m; done
EDIT:

I found that the C standard library function "atof" (it converts text to a floating point number, and I would assume that this is what sleep uses) converts "inf" and "infinity" to an infinite value.

I tried this and it seems to work:

Code:
sleep inf

Last edited by MTK358; 05-18-2011 at 02:58 PM.
 
1 members found this post helpful.
Old 05-18-2011, 03:47 PM   #6
Nominal Animal
Senior Member
 
Registered: Dec 2010
Location: Finland
Distribution: Xubuntu, CentOS, LFS
Posts: 1,723
Blog Entries: 3

Rep: Reputation: 948Reputation: 948Reputation: 948Reputation: 948Reputation: 948Reputation: 948Reputation: 948Reputation: 948
If you want to detach something from a script -- for example, from a startup script or a terminal --, use
Code:
( setsid command ... & ) </dev/null &>/dev/null
That command will run completely separately from the calling script and/or terminal. It will keep running even if you log out, for example.

For normal session commands, use
Code:
command ... &
command ... &
command ... &

wait
This way, when you exit, the process group will be sent a TERM signal, and all the commands will be terminated. The script will not exit normally unless all of the commands have exited.
 
Old 05-20-2011, 05:06 PM   #7
kopatops
Member
 
Registered: Mar 2010
Distribution: Arch Linux
Posts: 45

Original Poster
Blog Entries: 1

Rep: Reputation: 16
Quote:
Originally Posted by MTK358 View Post
[...]
I found that the C standard library function "atof" (it converts text to a floating point number, and I would assume that this is what sleep uses) converts "inf" and "infinity" to an infinite value.

I tried this and it seems to work:

Code:
sleep inf
Yes, man - floating point it is. Thanks!
Should have tested this on my own . It does seem to work. I'll then just put sleep inf as the last line of my "DE" script and do a killall mo-de to end .xinitrc and thereby the x-session... Feel free to object if there is a more elegant/portable/obvious way to acheive what I want

Quote:
Originally Posted by Nominal Animal View Post
If you want to detach something from a script -- for example, from a startup script or a terminal --, use
Code:
( setsid command ... & ) </dev/null &>/dev/null
That command will run completely separately from the calling script and/or terminal. It will keep running even if you log out, for example.
So, then

Code:
( setsid compiz ... & ) </dev/null &>/dev/null
will make compiz (my window manager) run in a new session, so parsing of the script can continue on to those extra lines I want in there. And still, the script won't end before the original command compiz has terminated, even though it is now "detached" from the script?

Am I way off? These process control techniques seem interesting, but I'm just learning about ps's, pgrp's, and session's, so I'm not sure I'll use this for some time. Just want to show my appreciation for the suggested solution; it doesn't seem to involve any extra software running at all, which is elegant.

Tnx all.

Last edited by kopatops; 05-20-2011 at 05:10 PM.
 
Old 05-21-2011, 11:33 AM   #8
Nominal Animal
Senior Member
 
Registered: Dec 2010
Location: Finland
Distribution: Xubuntu, CentOS, LFS
Posts: 1,723
Blog Entries: 3

Rep: Reputation: 948Reputation: 948Reputation: 948Reputation: 948Reputation: 948Reputation: 948Reputation: 948Reputation: 948
Quote:
Originally Posted by kopatops View Post
So, then

Code:
( setsid compiz ... & ) </dev/null &>/dev/null
will make compiz (my window manager) run in a new session, so parsing of the script can continue on to those extra lines I want in there. And still, the script won't end before the original command compiz has terminated, even though it is now "detached" from the script?
Just the opposite: with the above, the script can exit without compiz getting killed. If I understood your situation correctly, that'd end your session.. so that's not what you want to do for compiz.

For compiz, you'll want to use
Code:
compiz ... &

# ... other commands to start in the background ...

wait
The single wait at the end makes the script wait for all of the commands started in the background -- compiz in this case -- to exit before the script ends. In other words, the script will sit in the wait command for as long as any of the backgrounded stuff is still running.
 
3 members found this post helpful.
Old 05-21-2011, 02:59 PM   #9
kopatops
Member
 
Registered: Mar 2010
Distribution: Arch Linux
Posts: 45

Original Poster
Blog Entries: 1

Rep: Reputation: 16
Quote:
Originally Posted by Nominal Animal View Post
Just the opposite: with the above, the script can exit without compiz getting killed. If I understood your situation correctly, that'd end your session.. so that's not what you want to do for compiz.

For compiz, you'll want to use
Code:
compiz ... &

# ... other commands to start in the background ...

wait
The single wait at the end makes the script wait for all of the commands started in the background -- compiz in this case -- to exit before the script ends. In other words, the script will sit in the wait command for as long as any of the backgrounded stuff is still running.
Oh, now I get it!

This is exactly what I need. Just a single wait... Huge thank you Nominal Animal.
 
Old 05-22-2011, 05:54 AM   #10
kopatops
Member
 
Registered: Mar 2010
Distribution: Arch Linux
Posts: 45

Original Poster
Blog Entries: 1

Rep: Reputation: 16
For anyone who reads this thread; you might find the following information useful.
I found it by accident on the arch wiki .xinitrc page: https://wiki.archlinux.org/index.php/Xinitrc

Quote:
Originally Posted by Arch Wiki
Alternative method

If you need to start your window manager before launching additional applications, use the following method:

Code:
#!/bin/bash

openbox & wmpid=$!

urxvtd -q -f -o &
xscreensaver -no-splash &
fbpanel &

wait $wmpid
The first line runs openbox as a background process and immediately stores the process id ($!) in the variable wmpid. On the last line, the wait builtin is used to wait until the process specified by wmpid terminates.
Using this method, the X session will still end with the window manager, but you can start processes before/after it as you see fit. Hence, the assumption in my original post:

Quote:
Originally Posted by kopatops View Post
I used to have my X session die with the Compiz process, but now I need to execute some things after Compiz in the script above, meaning I have to background it.
is not really true. Useful to note this fact
Thanks everyone. Won't touch the thread anymore by myself.

Last edited by kopatops; 05-22-2011 at 06:04 AM.
 
1 members found this post helpful.
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
[SOLVED] Lampp won't start Apache..."another web server daemon running". Ubuntu 9.10 rgannon Linux - Newbie 3 02-18-2013 04:15 AM
Removing the Enlightenment Sound Daemon (aka "esd" aka "esound") jgombos Debian 4 03-30-2010 02:33 PM
OpenVPN says "Starting virtual private network daemon. [OK]" but then nothing happens Posilo Linux - Newbie 4 05-25-2008 05:41 AM
Boot freezes at "Starting HAL daemon" after Kernel recompile DiBosco Linux - Software 2 04-14-2007 05:53 AM
"kdesu" daemon gives error message & all terminal emulators hang hari_seldon99 Mandriva 0 07-28-2004 04:30 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Software

All times are GMT -5. The time now is 02:32 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration