Solved

How to bring an orphaned process to foreground ?

Posted on 2004-05-02
7
581 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
Comment Utility
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
Comment Utility
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
Comment Utility
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
Free Trending Threat Insights Every Day

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

 
LVL 12

Expert Comment

by:stefan73
Comment Utility
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
Comment Utility
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
Comment Utility
PAQed - no points refunded (of 130)

Computer101
E-E Admin
0

Featured Post

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
Where is my core dump file in Ubuntu? 12 424
LDAP server on Linux Redhat 6 2 487
OS & DB Recommendation 4 45
Error while starting init script 2 84
The purpose of this article is to fix the unknown display problem in Linux Mint operating system. After installing the OS if you see Display monitor is not recognized then we can install "MESA" utilities to fix this problem or we can install additio…
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…
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…
This video shows how to remove a single email address from the Outlook 2010 Auto Suggestion memory. NOTE: For Outlook 2016 and 2013 perform the exact same steps. Open a new email: Click the New email button in Outlook. Start typing the address: …

763 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

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now