0

I have a process, x, which has the PPID (listed by ps) or the process -bash started about a month ago..

myuser+ 11861 11858  0 Jun13 pts/178  00:00:00 -bash
myuser+ 16321 11861  8 Jun13 pts/178  2-01:07:02 myprocessx

Does this mean someone started my process x from bash with e.g. nohup?

I want to know as want to restart the process but cannot be sure they have some other process manager, e.g. supervisor for managing the process, and want to use whatever was used to start the current process..

1
  • Do ps with -o including one of start start_time/stime lstart bsdstart and other things like ,pid,uid,tty,comm/args as needed. If 16321 was created after 11858 then yes it was created by the (probable) login shell in 11858. If 16321 was created before 11858 then it was created by a prior process using the same pid that died and was reaped and the pid was reallocated to that login bash. ps can't tell you if it used nohup; even looking at the sigmask won't tell you for sure unless you know what (all!) the code in myprocessx does (and if it has changed, what it used to do). Jul 7, 2017 at 7:46

1 Answer 1

1

When a process is started it is done via the system call execve. The first argument to this call is the path to the executable. The second can be chosen arbitrarily, by usually it is the name of the program to be executed. (After this follow the command line arguments.) This second argument is what you see in ps.

By convention, login shells are started with a - prepended to this name. So your -bash process is a login instance of bash.

2
  • 2
    The first argument cannot be arbitrary. The real path (or program name if a path search is being done) comes first and then the potentially fake name is the second argument.
    – thrig
    Jul 6, 2017 at 14:02
  • Thank you for correcting my answer. I confused the first argument to the whole execve()-call with the first element in the array (following as 2nd arg for execve))
    – ohno
    Jul 10, 2017 at 13:11

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .