getlogin in libc.so

Posted by dmikai on 08-Sep-2011 09:51

Hi

I have some code wich retrieve UNIX initial login name of user:

procedure getlogin external "libc.so" cdecl:                                                                                               

DEFINE RETURN PARAMETER login_char AS MEMPTR NO-UNDO.                                                                             

end procedure.                                                                                                                           


def var login_char as memptr.                                                                                                         

def var s as char.                                                                                                                                                                                                 

run getlogin(output login_char).

assign s = get-string(login_char,1) no-error.


disp s.

But s is aways empty.

I need help.

OpenEdge 10.1B03 64Bit

SunSparc Solaris 5.10 64Bit

All Replies

Posted by gus on 08-Sep-2011 15:12

Try adding a

    set-size (login_char) = 256.

before the run getlogin (output login_char) .

Posted by egarcia on 08-Sep-2011 15:22

Some suggestions:

The function getlogin(void) requires the process to be run from a terminal.

Is the process being run from a terminal?

Can the terminal be found in /var/adm/utmpx? (strings /var/adm/utmpx)

This thread is closed