LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
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 03-05-2011, 03:11 PM   #1
Linux.tar.gz
Senior Member
 
Registered: Dec 2003
Location: Paris
Distribution: Slackware forever.
Posts: 2,534

Rep: Reputation: 100Reputation: 100
Tricky problem, full detaching process inside a script.


Hi.

I want to change Xfce layout on-the-fly :

I created an install script.

If i launch it, it does not work.
If i execute it manually, it works like a charm.

I searched for days, but i now give up TT. That's why i request your help...

Code:
#!/bin/sh

/usr/bin/xfce4-panel -x

killall xfconfd

#the Xfce settings
cp -r /etc/xdg/xfce-custom-settings/* $HOME/.config/

setsid sh -c 'cd / && xfwm4 --replace ... & :' > /dev/null 2>&1 < /dev/null

sleep 4

setsid sh -c 'cd / && xfce4-panel& ... & :' > /dev/null 2>&1 < /dev/null
The only explanation i found is, as the script is launched under a xfwm4 instance, this instance is "memorized" all script long, so, as xfwm4 is relaunched, nothing happens.

Does someone has an idea about how to "isolate" this script from it's dependency ?

Last edited by Linux.tar.gz; 03-05-2011 at 03:14 PM.
 
Old 03-06-2011, 02:02 PM   #2
corp769
LQ Guru
 
Registered: Apr 2005
Location: /dev/null
Posts: 5,818

Rep: Reputation: 1007Reputation: 1007Reputation: 1007Reputation: 1007Reputation: 1007Reputation: 1007Reputation: 1007Reputation: 1007
With what you are doing, you should be able to use nohup or disown.

Cheers,

Josh
 
Old 03-06-2011, 02:13 PM   #3
Linux.tar.gz
Senior Member
 
Registered: Dec 2003
Location: Paris
Distribution: Slackware forever.
Posts: 2,534

Original Poster
Rep: Reputation: 100Reputation: 100
Yup, already tried that, with the same result.

I think i have to launch the process detached in another tty...

I don't know how.
 
Old 03-06-2011, 02:29 PM   #4
corp769
LQ Guru
 
Registered: Apr 2005
Location: /dev/null
Posts: 5,818

Rep: Reputation: 1007Reputation: 1007Reputation: 1007Reputation: 1007Reputation: 1007Reputation: 1007Reputation: 1007Reputation: 1007
Hmmm.... You are talking about isolating the "setsid sh -c..." correct?
 
Old 03-06-2011, 04:19 PM   #5
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
Use a subshell to isolate it from the job list on the current shell, then use setsid and ampersand to run it on the background (in parallel to the original script) in a separate session.
Code:
( setsid sh -c ' ... commands ... ' </dev/null >/dev/null 2>/dev/null & )
 
  


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] Problem with a function having a background process inside a command substitution rylphs Linux - Newbie 2 10-05-2010 10:36 AM
detaching a (graphical)process invoked without "&" from terminal deepclutch Programming 2 06-07-2010 09:20 AM
How to get full path to script file inside script itself? And in case of sym links? maggus Linux - Newbie 3 05-28-2009 08:40 AM
Detaching Amarok from bash script run from KMenu srunni Linux - Software 7 08-12-2008 02:09 AM
how do i kill a process from inside a bash script? mikaelo Programming 4 05-28-2004 08:51 AM

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

All times are GMT -5. The time now is 05:33 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