Solved

How to bring an orphaned process to foreground ?

Posted on 2004-05-02
7
595 Views
Last Modified: 2008-02-26
Hi.

This is the situation I have.

1. Process "p0" forks (started form terminal).
2. Child "exec"s process "p1"
3. Process "p0" terminates leaving child orphaned.

Now p1 need to read keyboard input. But since it is a background process it can not.

How to solve this ?

Maybe I can bring child to foreground or regain control over terminal ?

Thank You.
0
Comment
Question by:lklm
7 Comments
 
LVL 12

Expert Comment

by:stefan73
ID: 10975489
Hi lklm,
> Now p1 need to read keyboard input. But since it is a background process
> it can not.

Maybe you can exec in p0 instead of p1?

Cheers,
Stefan
0
 

Author Comment

by:lklm
ID: 10975993
Hi

Unfortunately I can't change the structure of application.
This is multi process application I have access to all the sources but I change change the arch.

Thanks
0
 
LVL 7

Expert Comment

by:glassd
ID: 10976291
Not sure if this will work but:

The command "jobs" should show the backgrounded job, if it is still associated with the terminal. If it is job 1 then:
fg %1
should bring it to the foreground.

Might be worth a try.
0
Master Your Team's Linux and Cloud Stack

Come see why top tech companies like Mailchimp and Media Temple use Linux Academy to build their employee training programs.

 
LVL 12

Expert Comment

by:stefan73
ID: 10976375
lklm,
Is p1 really an interactive process? Or do you want to "remote control" its I/O from p0?

Stefan
0
 
LVL 8

Expert Comment

by:Anthony2000
ID: 10983085
I am assuming that once p0 terminates, process p1 loses its associated terminal and becomes owned by init.

Is there a reason why you cannot change the point where p0 is forked so that the parent just waits until the child is finished before exiting. Shell programs do this all the time. In your case when you return to your parent, have the parent exit then, instead of after it forks and execs to p1.

Does this make sense?

Anthony.
0
 
LVL 1

Accepted Solution

by:
Computer101 earned 0 total points
ID: 12243972
PAQed - no points refunded (of 130)

Computer101
E-E Admin
0

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Percona cluster member randomly crash 15 534
Ubuntu 16.04 Emergency Boot 2 210
busybox bash/ash - bash -x | grep 19 152
awk sed 8 65
Have you ever been frustrated by having to click seven times in order to retrieve a small bit of information from the web, always the same seven clicks, scrolling down and down until you reach your target? When you know the benefits of the command l…
The purpose of this article is to demonstrate how we can upgrade Python from version 2.7.6 to Python 2.7.10 on the Linux Mint operating system. I am using an Oracle Virtual Box where I have installed Linux Mint operating system version 17.2. Once yo…
Established in 1997, Technology Architects has become one of the most reputable technology solutions companies in the country. TA have been providing businesses with cost effective state-of-the-art solutions and unparalleled service that is designed…
Nobody understands Phishing better than an anti-spam company. That’s why we are providing Phishing Awareness Training to our customers. According to a report by Verizon, only 3% of targeted users report malicious emails to management. With compan…

856 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question