I submitted this over on RT as well, but your sourceforge
page looked lonely, so...
The ttynum value returned on HPUX is invalid. The
current code, using makedev,
returns a rather large integer, or a negative int if their is
no tty associated with
the process.
A better approach in my opinion would be to use the
devnm() function and simply
return a string for the ttyname, or undef if there is no
associated tty.
Here's a bit of sample code, partially lifted from a post
by Dan Mercer in
comp.unix.programmer:
#include <devnm.h>
...
char path[MAXPATHLEN+1]; /* from sys/param.h */
struct pst_status pst;
...
if(pst.pst_term.psd_major != -1){
devnm(S_IFCHR, /* from sys/stat.h */
(dev_t)((pst.pst_term.psd_major<<24)
|pst.pst_term.psd_minor),
path,
sizeof path,
1);
}
Then "path" will contain something like "/dev/pty/ttyp4",
for example. You could
always strip out the leading "/dev/xxx" junk, too, if you'd
like to keep it closer to
what a ps -ef returns.
Anyway, that's what I'm doing for the Ruby port. :)
Regards,
Dan