[SOLVED] Does anyone know of a daemon that in essence "does nothing"?
Linux - SoftwareThis 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
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
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.
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.
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
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
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!
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.
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.
[...]
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
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.
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.
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.
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:
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
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.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.