linux-c-programming.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: vadiraj <vadis.list@gmail.com>
To: linux-c-programming@vger.kernel.org
Subject: getutline (3) fails on a daemon process
Date: Tue, 12 Jun 2007 20:31:57 +0530	[thread overview]
Message-ID: <1181660517.5483.8.camel@blr-img.blr.novell.com> (raw)

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





             reply	other threads:[~2007-06-12 15:01 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-06-12 15:01 vadiraj [this message]
2007-06-12 15:19 ` getutline (3) fails on a daemon process Glynn Clements

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1181660517.5483.8.camel@blr-img.blr.novell.com \
    --to=vadis.list@gmail.com \
    --cc=linux-c-programming@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).