System Administration
cancel
Showing results for 
Search instead for 
Did you mean: 

ps: don't know which terminal to select

P_F
Regular Advisor

ps: don't know which terminal to select

This script works on Linux 4.X and 5.X
This script works on AIX 5.X
This script works on HPUX if running directly on the command line
ONLY If run from cron I get this error:

(HP-UX B.11.23 U ia64 )

ps: don't know which terminal to select
ps: don't know which terminal to select
ps: don't know which terminal to select
ps: don't know which terminal to select

Here is the relevant code:

#!/usr/bin/ksh


....

manage_ssh_ps $HOST &


...

PLEASE NOTE:

I have read about this patch PHCO_30559:

http://www13.itrc.hp.com/service/patch/patchDetail.do?patchid=PHCO_33267&sel={hpux:11.00,}&BC=main|search|patchDetail{PHCO_33267,{hpux:11.00,}}|cart|

The test for the conditions described do not match, in particular

$ ps < /dev/null 1> /tmp/out 2> /tmp/err
$ echo $?
1
$ cat /tmp/out --- This does not give any output.
$ cat /tmp/err
ps: don't know which terminal to select


cat /tmp/out
-- outputs normal ps info
cat /tmp/err
-- is empty

Furthermore the patch is for a different OS load.
17 REPLIES
Shibin_2
Honored Contributor

Re: ps: don't know which terminal to select

>> This script works on HPUX if running directly on the command line
ONLY If run from cron I get this error:

What is the user in both condition?
Regards
Shibin
P_F
Regular Advisor

Re: ps: don't know which terminal to select

The user is root.
Bill Hassell
Honored Contributor

Re: ps: don't know which terminal to select

> Here is the relevant code:
> #!/usr/bin/ksh
> ....
> manage_ssh_ps $HOST &

Not very useful.
What is manage_ssh_ps?

Post the results of this command:

# what /usr/bin/ps


Bill Hassell, sysadmin
Dennis Handly
Acclaimed Contributor

Re: ps: don't know which terminal to select

>The test for the conditions described do not match, in particular
ps: don't know which terminal to select

Either they broke this with PHCO_30559 or it never worked?
Note: A crontab job doesn't have a controlling terminal.

It appears what you want conflicts with the documentation:
(none) Select those processes associated with the current terminal.

Since there is no current terminal, you get that error.
P_F
Regular Advisor

Re: ps: don't know which terminal to select

Sure, looks like a bug.
Dennis Handly
Acclaimed Contributor

Re: ps: don't know which terminal to select

>looks like a bug.

What is the output on Linux and AIX when there is no controlling terminal?
What did you want to see?
P_F
Regular Advisor

Re: ps: don't know which terminal to select

The script does not error on AIX and Linux. Only on HPUX when invoked via cron does the script have issues managing a terminal.

In this case the script is being run on 11.23 but in the patch description - for a similar issue - on 11.00 there exists a condition in which the way the terminal was being assigned needed fixing. But that patch mentioned nothing about cron.

Regards, putting a process in the background in korn shell, via cron, on 11.23 consistently is causing errors.
Bill Hassell
Honored Contributor

Re: ps: don't know which terminal to select

I see the text inside the ps executable but I don't understand why ps would ever care about anything except stdout and stderr. But after trying it on 10.20, 11.00, 11.11, 11.23 and 11.31, it always reports the error:

for x in 2 3 4 5 6^Jdo^Jssh atl$x ps^Jdone
ps: don't know which terminal to select
ps: don't know which terminal to select
ps: don't know which terminal to select
ps: don't know which terminal to select
ps: don't know which terminal to select

I get the same results for remsh and rexec. So what does ps need that uname (for instance) doesn't need? AFAIK ps isn't interactive and doesn't read anything from stdin. Seems like a bug to me...even if it has been that way for more than 10 years.


Bill Hassell, sysadmin
Dennis Handly
Acclaimed Contributor

Re: ps: don't know which terminal to select

>The script does not error on AIX and Linux.

That's not what I was asking. What output does it produce? If there is no controlling terminal, are you happy with empty output?

Are you happy with the current shell and ps itself?

>But that patch mentioned nothing about cron.

The code change looks at the controlling terminal for the process and there is none.

>via cron, on 11.23 consistently is causing errors.

Yes, that is a consequence of the bug fix.

>Bill: I don't understand why ps would ever care about anything except stdout and stderr.

Did you read the man page:
(none) Select those processes associated with the current terminal.

You could say, if no current terminal, there is nothing to display.

>So what does ps need?

Something to select which processes to start displaying.
This only happens if you don't provide ps(1) any options.
P_F
Regular Advisor

Re: ps: don't know which terminal to select

> Are you happy with the current shell and ps itself?

No, the script malfunctions only produces the error message "ps: don't know which terminal to select" then will fail entirely and terminate.
P_F
Regular Advisor

Re: ps: don't know which terminal to select

I have opened an HP case on this. They have responded with suggestions. I'll give those a try today, time permitting, and respond.
P_F
Regular Advisor

Re: ps: don't know which terminal to select

For those following this thread or have this issue in the future:

HP provided what I would call a work around. Let me provide a bit more code associated with this issue:

################################

# this function open ssh session
manage_ssh_ps $HOST &
PS_VAL=$!

....
#do some things
...
ps -f | grep $PS_VAL
########################

They recommended I use the "-e" option

When I changed
ps -f
to
ps -ef

The terminal warnings stopped.


The comment I received from HP was:

"...the issue could happen even running from a tty and the session leader process relinquishes or killed. This is the intended behavior".

So, that's pretty much it.
P_F
Regular Advisor

Re: ps: don't know which terminal to select

I'm going to work with this for a while and if the problem goes away I'll close this thread.
Dennis Handly
Acclaimed Contributor

Re: ps: don't know which terminal to select

>ME: Are you happy with the current shell and ps itself?

I should have said, "Would you be happy ..."

>the script malfunctions only produces the

This is not what I'm asking.
First what is the output for AIX and Linux?

And if HP-UX were to change things, would you be happy with outputting lines only for the current shell and ps itself?
P_F
Regular Advisor

Re: ps: don't know which terminal to select

> First what is the output for AIX and Linux?

The output from the complete and successful invocation of the script is a cat command against the syslog. This works properly in AIX and Linux.

The problem in HPUX centers around dropping the ssh function in the background within the script, via cron. Then checking it with:

ps -f | grep

I would not expect ps to react with a terminal error. I don't understand why ps has a problem with the terminal.

I've read the man page on both
ps -ef ( causes the error to go away )
and
ps -f ( causes terminal error )

There's nothing in it indicating a terminal error might result.

> And if HP-UX were to change things, would you be happy with outputting lines only for the current shell and ps itself?

Why 1 type of argument creates a terminal error and the other does not seems odd. Sure, one can expect different results but not a failure, imho.

In regards to being happy... well, I've changed to using -ef and the script is working. So, I'm happy. I guess I'll
avoid using the -f option by itself when putting processes in the background
P_F
Regular Advisor

Re: ps: don't know which terminal to select

Closing thread.
Found a work around.
Dennis Handly
Acclaimed Contributor

Re: ps: don't know which terminal to select

>The output from the complete and successful invocation of the script is a cat command

I only care about what you expect ps to produce in a cron job?
What is the EXACT output of ps for Linux or AIX? And what do you do with that output?

>I don't understand why ps has a problem with the terminal.

Because the ps default is to produce output of all processes of the controlling terminal. If none, what should it output, nothing?