getutline (3) fails on a daemon process

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi List,

I'm trying to fetch userid using utmp.h API's. I'm able to get the
userid from the funciton getutline(3) on normal process. But the
same function while called by a daemon process it fails with perror
"no such process".

Any Idea why this is failing on a daemon process? 

here is the sudo code of the program I'm using.


    struct utmp *out_entry ;
    out_entry = calloc(1,sizeof(struct utmp));
    if(out_entry == NULL)
        return -1;

    strcpy (out_entry->ut_line,"pts/0") ;
    out_entry = getutline(out_entry) ;
    if(out_entry != NULL){
        strcpy(username,out_entry->ut_user) ;
        return 0;
    }
    

I have no alternate to get the username, other calls are of no fruit to
me. Only this call is of use to me and it does work on a normal process.
It fails only if the same code is run as a daemon process.


Thanks in advance


Regards,
Vadiraj




-
To unsubscribe from this list: send the line "unsubscribe linux-c-programming" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html

[Index of Archives]     [Linux Assembler]     [Git]     [Kernel List]     [Fedora Development]     [Fedora Announce]     [Autoconf]     [C Programming]     [Yosemite Campsites]     [Yosemite News]     [GCC Help]

  Powered by Linux