LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.

Notices


Reply
  Search this Thread
Old 10-13-2009, 08:13 AM   #1
Sarah_Student
LQ Newbie
 
Registered: Oct 2009
Posts: 7

Rep: Reputation: 0
Different PID with & and ps


Hi
I use Linux Suse Enterprise server 10.
I have installed mc on it.
While sending mc to background with mc & I receive a PID for example 7521 but when I use ps command to check the active processes, this PID (7521) is assigned to bash process and mc ID has changed to some thing more, for example 7525.
Can any one explain me the reason? For other processes that I have checked, the assigned PID is same.
Thanks in advance.
 
Old 10-13-2009, 11:04 AM   #2
catkin
LQ 5k Club
 
Registered: Dec 2008
Location: Tamil Nadu, India
Distribution: Debian
Posts: 8,578
Blog Entries: 31

Rep: Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208
Please post the line you are using to send mc to background with mc &
 
Old 10-18-2009, 01:26 AM   #3
Sarah_Student
LQ Newbie
 
Registered: Oct 2009
Posts: 7

Original Poster
Rep: Reputation: 0
I use these lines...
mc &
[1] 5704
ps
5502 pts/1 00:00:00 bash
5704 pts/1 00:00:00 bash
570B pts/1 00:00:00 mc
5710 pts/1 00:00:00 ps
[1]+ stopped mc
 
Old 10-18-2009, 06:42 AM   #4
catkin
LQ 5k Club
 
Registered: Dec 2008
Location: Tamil Nadu, India
Distribution: Debian
Posts: 8,578
Blog Entries: 31

Rep: Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208
Intriguing. Here's equivalent from Slackware 13.0 (sorry -- don't know how to find version of mc; the -V option doesn't give it, grepping all the /var/log/packages files for /usr/bin/mc doesn't find it ...)
Code:
c:~$ mc &
[1] 7478
c:~$ ps
                         PID TTY          TIME CMD
 7116 pts/2    00:00:00 bash
 7478 pts/2    00:00:00 mc
 7481 pts/2    00:00:00 ps

[1]+  Stopped                 mc
c:~$ type mc
mc is hashed (/usr/bin/mc)
c:~$ file /usr/bin/mc
/usr/bin/mc: ELF 32-bit LSB executable, Intel 80386, version 1 (SYSV), dynamically linked (uses shared libs), stripped
 
Old 10-18-2009, 01:15 PM   #5
itz2000
Member
 
Registered: Jul 2005
Distribution: Fedora fc4, fc7, Mandrake 10.1, mandriva06, suse 9.1, Slackware 10.2, 11.0, 12.0,1,2 (Current)]
Posts: 732

Rep: Reputation: 30
Code:
root@Peanut:/home/donkey# vim &
[1] 3404
root@Peanut:/home/donkey# ps
  PID TTY          TIME CMD
 3373 pts/0    00:00:00 bash
 3404 pts/0    00:00:00 vim That's how it should be
 3405 pts/0    00:00:00 ps

[1]+  Stopped                 vim
root@Peanut:/home/donkey# ps
  PID TTY          TIME CMD
 3373 pts/0    00:00:00 bash
 3404 pts/0    00:00:00 vim
 3406 pts/0    00:00:00 ps
root@Peanut:/home/donkey# ps
  PID TTY          TIME CMD
 3373 pts/0    00:00:00 bash
 3404 pts/0    00:00:00 vim
 3407 pts/0    00:00:00 ps
root@Peanut:/home/donkey# kill %1

[1]+  Stopped                 vim
The reason is simple, you actually don't run mc, but running bash that run mc.
do the commands :
Code:
export
ls -l `which mc`
strace mc
and post the results here so we can point out why it happened
 
Old 10-19-2009, 01:01 AM   #6
Sarah_Student
LQ Newbie
 
Registered: Oct 2009
Posts: 7

Original Poster
Rep: Reputation: 0
My output for vim is same as yours.
I think because mc is visual view of shell, first, shell should run and then mc.
Output of the commands you have written is very long.
Should I send it anyway?
 
Old 10-19-2009, 04:49 PM   #7
itz2000
Member
 
Registered: Jul 2005
Distribution: Fedora fc4, fc7, Mandrake 10.1, mandriva06, suse 9.1, Slackware 10.2, 11.0, 12.0,1,2 (Current)]
Posts: 732

Rep: Reputation: 30
Quote:
Originally Posted by Sarah_Student View Post
My output for vim is same as yours.
I think because mc is visual view of shell, first, shell should run and then mc.
Output of the commands you have written is very long.
Should I send it anyway?
yeah why not, so we can learn about this a little more and teach some stuff...
 
  


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 On
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
pls tell difference between waitpid(pid,&status,0) and waitpid(pid,&status,WNOHANG) nagendrar Linux - Newbie 3 07-08-2009 08:51 PM
Glassfish - Obtain Name & PID and format output j-me Linux - General 1 04-10-2009 03:02 PM
usb bluetooth modify vid & pid scan73 Linux - Newbie 1 02-11-2008 10:35 PM
/var/run/[XXX].pid - Tcl pid code liguorir Linux - Software 1 05-20-2004 10:32 PM
ERROR: Couldn't write pid to pid file lawrencegoodman Linux - Newbie 2 02-13-2004 08:05 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - General

All times are GMT -5. The time now is 02:05 AM.

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