LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   ps command - question mark query (https://www.linuxquestions.org/questions/linux-newbie-8/ps-command-question-mark-query-4175441066/)

vicky007aggrwal 12-11-2012 11:36 PM

ps command - question mark query
 
I am seeing the question mark(?) in ps command output.I know that means no terminal has been attached to it but i dont know under which all scenarios this will happen.

does this happen

1)for running process in backgroud ??

2) for init process ??

3) for any process started with nohup. ???

4) for running init script using service manually ??

Can you please help me in understand the possible scenarios

vicky007aggrwal 12-11-2012 11:39 PM

any detailed documentation /web link will be a great help

redfox2807 12-12-2012 12:45 AM

May be this link would be of any help.

vicky007aggrwal 12-12-2012 01:39 AM

Thanks for the link
but how does the processes get disconnected themselves from their controlling terminals.ANy idea..

markush 12-12-2012 01:50 AM

It's the fork command.

Markus

redfox2807 12-12-2012 01:52 AM

Deamons never have any controlling terminals. That's what they are intended for. As far as I know technically they're direct children of init process.

Following the Markus' comment, here's more details on how to daemonize a process

vicky007aggrwal 12-12-2012 02:26 AM

Thanks redfox2807 , but i want to know that how we can predict by looking at the ps command output that whether the process is started by user terminal or not.

What i have experienced that certain processes which i start even those also showing question mark in there ps output not "tty terminal"

I want to know the scenarios under which the process will show Question Mark (?) in the ps command output even when it is triggered by a user(who logged onto the linux terminal)

Any clues on how to confirm this information
. pls suggest

redfox2807 12-12-2012 02:46 AM

You can't have this sort of information without knowing what kind of program you start I think. The latest link has an example of a program that's run via a terminal but dissociates itself from the controlling terminal. It's a normal practice for many daemons like smbd to drop its privileges to a special user

I wonder why you are even concerned about controlling terminals. Having one or not just affects the way you interact with a program, you are in charge over it anyways

vicky007aggrwal 12-12-2012 02:51 AM

actually we have a requirement in which we want to be sure that a process is getting triggered by a user. This information i was thinking to get from PS command teminal column output.

But if a process dissociates from the terminal , then we cannot find this detail that what you mean ?? So no way out is it ???

redfox2807 12-12-2012 03:40 AM

Could you be more specific? A program is always started by a user (i.e. with some user privileges) with the exception of init, that is triggered by Linux kernel directly. init defines and operates the whole user space. All the processes it triggers are run as root. Then in case of CLI login command is run. That's where a physical user comes into interaction with the system. As far as I can cogitate your intentions, your question goes to the area of user privileges, to define what a user is allowed to run and what's not. Maybe I'm just completely missing your point.

theNbomr 12-12-2012 09:41 AM

The concept of 'controlling terminal' is distinct from parental ancestry. All processes are children of some other process. The ps command shows the Parent Process ID (PPID). Is that the information you really want?
Any process can dissociate itself from a controlling terminal. Processes that do so are called daemons. Typically, these are launched as part of the system startup. Normally, a process is killed if it's controlling terminal closes (say, if the SSH connection is broken, or the modem hangs up, or an xterm gets closed). Daemon processes need to stay running perpetually, so cannot rely on a controlling terminal in order to stay alive.

--- rod.


All times are GMT -5. The time now is 01:41 AM.