ps command returns a "?"


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers ps command returns a "?"
# 1  
Old 09-22-2006
ps command returns a "?"

When I do the following command where jxh777 is my userid to see my processes, I see a question mark in the return. Does that mean anything ?

ps -ef | grep jxh777

jxh777 9966 9965 0 16:47:46 pts/tb 0:00 -ksh
jxh777 11660 9966 1 17:05:02 pts/tb 0:00 grep jhabi0
jxh777 28162 28160 0 13:49:38 ? 0:00 perl ./Mob.pl

Thanks in advance for your insight
# 2  
Old 09-23-2006
That field is the controlling terminal. When there is ? mark it means that process has no controlling terminal. A process with no controlling terminal is a deamon. It cannot open /dev/tty. And there is no terminal where you could type cntl-c to interrupt it. The process may have been started by another daemon such as cron.
# 3  
Old 09-23-2006
Quote:
Originally Posted by Perderabo
That field is the controlling terminal. When there is ? mark it means that process has no controlling terminal. A process with no controlling terminal is a deamon. It cannot open /dev/tty. And there is no terminal where you could type cntl-c to interrupt it. The process may have been started by another daemon such as cron.
i have some kind of clarification here..

can all the process without a controlling terminal be termed as a daemon ? ....
isnt that a daemon should necessarily be a session leader ... >>> Smilie
# 4  
Old 09-23-2006
Quote:
Originally Posted by matrixmadhan
i have some kind of clarification here..

can all the process without a controlling terminal be termed as a daemon ? ....
isnt that a daemon should necessarily be a session leader ... >>> Smilie
Good heavens, no!

A program like "cron" needs to be able to daemonize itself. That is, I should be able to start cron from a tty. If I do that, cron will have a controlling terminal when it first starts to run. To lose that controlling terminal (on a Posix compliant system), a sequence of steps is needed which does indeed include becoming a session leader. I believe that this may be what you are thinking of. However, this is just a transitory state. A correctly written modern daemon will then fork(). The parent (a session leader) will exit. The child (not a session leader) will then strive to run forever. Since it is not a session leader, it can open a tty device without acquiring it as a controlling terminal. In the old days, a daemon would need to fork() every time it wanted to write on /dev/console. The child would open /dev/console, write(), then exit().

And that brings up an interesting point. The session concept arose during the 90's. Until there were sessions, a process could not be a session leader. But early versions of unix, although they lacked sessions, did indeed have daemons. "No controlling terminal" is the definition of daemon that I learned in the early 80's. I have never seen anything to challenge that. But I don't think that "daemon" has its definition controlled by a standards body or anything like that.

1.7 How do I get my program to act like a daemon?
# 5  
Old 09-23-2006
Just to illustrate what Perderabo has
Code:
(  tail -f /var/log/syslog & )
#exit from session

The tail -f will continue to run without a tty.
# 6  
Old 09-23-2006
Quote:
Originally Posted by reborg
Just to illustrate what Perderabo has
Code:
(  tail -f /var/log/syslog & )
#exit from session

The tail -f will continue to run without a tty.
This is a different case than what I had in mind and more explanation is in order. When a session leader with a controlling terminal exits, the terminal is yanked away from the session. Posix demands that a HUP be delivered to the foreground process group. Also, suppose that a background job had been suspended because it wanted tty input. There will be no way for it to resume. So if any process a background process group is stopped, the entire group will be sent a HUP followed by a CONT. Some OS's will send a HUP to all background processes. Regardless, a process can ignore HUP and continue to function. Any process groups that continue to run after the session leader has exited are called orphaned. A member of a orphaned process group cannot read nor write to its controlling terminal nor will it recieve any signals from key presses on the terminal. However with most OS's, the controlling terminal remains open and this may show up in the ps output. The close() system call is supposed to succeed although any buffered data is discarded.

As this page says:
Quote:
The terminal-driver repeatedly does the foreground/background/orphaned process-group check whenever a process tries to access the terminal.
Poor jxh461 probably is beginning to regret the question. Smilie
# 7  
Old 09-23-2006
Actually, I was only reponding to this bit Smilie

Quote:
Originally Posted by perderabo
Good heavens, no!
Certianly worth your effort though, it's great to have this information available on the site.
 
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

Using "mailx" command to read "to" and "cc" email addreses from input file

How to use "mailx" command to do e-mail reading the input file containing email address, where column 1 has name and column 2 containing “To” e-mail address and column 3 contains “cc” e-mail address to include with same email. Sample input file, email.txt Below is an sample code where... (2 Replies)
Discussion started by: asjaiswal
2 Replies

2. Shell Programming and Scripting

Source command returns error when it strikes conditional statement "ifeq"

Hello All, I am running source command on my project configuration file app.cfg which has conditional statements with make file systax E.g ifeq ($(APP_CMP_DIR),trunk). When I source this file it throws error: syntax error near unexpected token... (1 Reply)
Discussion started by: anand.shah
1 Replies

3. Shell Programming and Scripting

sed returns error "sed: -e expression #1, char 18: unterminated `s' command"

Hello All, I have something like below LDC100/rel/prod/libinactrl.a LAA2000/rel/prod/libinactrl.a I want to remove till first forward slash that is outputshould be as below rel/prod/libinactrl.a rel/prod/libinactrl.a How can I do that ??? (8 Replies)
Discussion started by: anand.shah
8 Replies

4. Solaris

Checking RAID health, metastat returns "no database"

Hello, I am supposed to check the RAID health of a system but when I type metastat it says "there are no existing databases" Does this mean that there is no RAID configured at all? Is there any other utility I should try? I know the system has two disks. Tanks! (8 Replies)
Discussion started by: cevspencer
8 Replies

5. Shell Programming and Scripting

awk command to replace ";" with "|" and ""|" at diferent places in line of file

Hi, I have line in input file as below: 3G_CENTRAL;INDONESIA_(M)_TELKOMSEL;SPECIAL_WORLD_GRP_7_FA_2_TELKOMSEL My expected output for line in the file must be : "1-Radon1-cMOC_deg"|"LDIndex"|"3G_CENTRAL|INDONESIA_(M)_TELKOMSEL"|LAST|"SPECIAL_WORLD_GRP_7_FA_2_TELKOMSEL" Can someone... (7 Replies)
Discussion started by: shis100
7 Replies

6. Shell Programming and Scripting

Command Character size limit in the "sh" and "bourne" shell

Hi!!.. I would like to know what is maximum character size for a command in the "sh" or "bourne" shell? Thanks in advance.. Roshan. (1 Reply)
Discussion started by: Roshan1286
1 Replies

7. UNIX for Dummies Questions & Answers

Command Character size limit in the "sh" and "bourne" shell

Hi!!.. I would like to know what is maximum character size for a command in the "sh" or "bourne" shell? Thanks in advance.. Roshan. (1 Reply)
Discussion started by: Roshan1286
1 Replies

8. Shell Programming and Scripting

if returns "unknown test operator"

Greetings, using ksh on Solaris, I am trying to identify the current version of a package installed on multiple servers using if statement in a precursor to upgrading. I have searched the forums and have found many hits, reviewed 3 pages and have tried the different variations noted there. Also... (3 Replies)
Discussion started by: 22blaze
3 Replies

9. UNIX for Dummies Questions & Answers

diff on c-source file always returns "files differ"

I have a c-source file that is evidently seen by unix as a binary file. When doing a diff between it and older versions with substantial differences, diff will only return "files differ". I have tried cat-ing the file to another file; tried using the "-h" on the diff; I have tried ftp-ing it... (7 Replies)
Discussion started by: C-Prog-Man
7 Replies

10. Programming

pthread_create returns "operation not permitted" if I try to link static?

Hello, I am trying to port some testtools we wrote from solaris to redhat linux(AMD64). If I link dynamic, set the correct LD_LIBRARY_PATH, everything runs fine. If I try to link static, the pthread_create returns "operation not permitted" (error code 1). Does anybody have an idea where to... (1 Reply)
Discussion started by: Micky
1 Replies
Login or Register to Ask a Question