Code in C to make a module pause?

Kenneth Goodwin kgoodwin at datamarktech.com
Fri Jul 2 17:02:52 UTC 2004


>  -----Original Message-----
>  From: pam-list-bounces at redhat.com
>  [mailto:pam-list-bounces at redhat.com]On
>  Behalf Of Jason Gerfen
>  Sent: Friday, July 02, 2004 12:46 PM
>  To: Pluggable Authentication Modules
>  Subject: Code in C to make a module pause?
>
>
>  I am not sure if this is the right place to ask this
seeing as it is
>  more of programming question in response to how to make a
list of
>  system() calls pause()?
>
>  The reason I ask is because PAM works as a shared object
so
>  there is no
>  interaction with the user / keyboard (after the login
information is
>  passed) and I would like to use the pause() function to
require the
>  module to wait until a system() command has finished,
>  without the need
>  to fork the process.

I am presuming by system() that you are refering to the LIBC
system() subroutine
The system() subroutine call works by forking and execing
the command named as it's
string variable parameter passed as part of the call (ie
system("/bin/who"); )
It is a simple C library function.

the fork is required in order to execute the command
specified. The system() call itself waits
until the command requested exits. This is in effective the
pause() you wish.

You can't Pause true system calls like open(), fork(), AND
exec() at all.
If I understand your question, then in the code snipnet
below --

i = 0;
system("/bin/who");
i++;


"i" does not get incremented to 1 UNTIL the /bin/who command
has completely executed and returned control
back to the calling program. This appears to be the
behaviour you are asking for.
If you are doiung a FORK() call before calling System(),
then you are probably being redunant as system() does
not require you to fork() before calling it. It does that op
itself.

If you wish different behaviour for system(), then do a "man
system".
the man page has a source Code example of how to roll your
own system() subroutine.





>
>  Anyone accomplish this before?
>
>  --
>  Jason Gerfen
>  Student Computing Group
>  Marriott Library
>  University of Utah
>  (801) 585-9810
>  jason.Gerfen at scl.utah.edu
>
>  "...Sometimes I just yell at myself. And it
>   makes me sad, sometimes I make myself cry..."
>  			~ My nephew Dawsyn
>
>
>
>  _______________________________________________
>  Pam-list mailing list
>  Pam-list at redhat.com
>  https://www.redhat.com/mailman/listinfo/pam-list
>





More information about the Pam-list mailing list