Solved

How to bring an orphaned process to foreground ?

Posted on 2004-05-02
7
585 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
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
shell script for killing a linux process 19 143
Ubuntu 16.04 Emergency Boot 2 169
Linux : adding the new user with password option, 11 97
Use Powershell script to ftp 10 83
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…
In this video I am going to show you how to back up and restore Office 365 mailboxes using CodeTwo Backup for Office 365. Learn more about the tool used in this video here: http://www.codetwo.com/backup-for-office-365/ (http://www.codetwo.com/ba…
As a trusted technology advisor to your customers you are likely getting the daily question of, ‘should I put this in the cloud?’ As customer demands for cloud services increases, companies will see a shift from traditional buying patterns to new…

895 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