* lib/nscd.c: Include defines.h.
* lib/nscd.c: Always warn when the nscd cache cannot be flushed. * lib/nscd.c: Avoid assignments in comparisons. * lib/nscd.c: Ignore the return value of fputs() when printing errors.
This commit is contained in:
parent
269d4c55dd
commit
ef1a2a82dd
@ -1,3 +1,11 @@
|
|||||||
|
2008-06-10 Nicolas François <nicolas.francois@centraliens.net>
|
||||||
|
|
||||||
|
* lib/nscd.c: Include defines.h.
|
||||||
|
* lib/nscd.c: Always warn when the nscd cache cannot be flushed.
|
||||||
|
* lib/nscd.c: Avoid assignments in comparisons.
|
||||||
|
* lib/nscd.c: Ignore the return value of fputs() when printing
|
||||||
|
errors.
|
||||||
|
|
||||||
2008-06-10 Nicolas François <nicolas.francois@centraliens.net>
|
2008-06-10 Nicolas François <nicolas.francois@centraliens.net>
|
||||||
|
|
||||||
* lib/port.c: Add brackets and parenthesis.
|
* lib/port.c: Add brackets and parenthesis.
|
||||||
|
17
lib/nscd.c
17
lib/nscd.c
@ -11,8 +11,11 @@
|
|||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
#include <sys/wait.h>
|
#include <sys/wait.h>
|
||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
|
#include "defines.h"
|
||||||
#include "nscd.h"
|
#include "nscd.h"
|
||||||
|
|
||||||
|
#define MSG_NSCD_FLUSH_CACHE_FAILED "Failed to flush the nscd cache.\n"
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* nscd_flush_cache - flush specified service buffer in nscd cache
|
* nscd_flush_cache - flush specified service buffer in nscd cache
|
||||||
*/
|
*/
|
||||||
@ -24,23 +27,27 @@ int nscd_flush_cache (const char *service)
|
|||||||
char *spawnedEnv[] = {NULL};
|
char *spawnedEnv[] = {NULL};
|
||||||
|
|
||||||
/* spawn process */
|
/* spawn process */
|
||||||
if( (err=posix_spawn(&pid, spawnedArgs[0], NULL, NULL,
|
err = posix_spawn(&pid, spawnedArgs[0], NULL, NULL,
|
||||||
spawnedArgs, spawnedEnv)) !=0 )
|
spawnedArgs, spawnedEnv);
|
||||||
|
if(0 != err)
|
||||||
{
|
{
|
||||||
fprintf(stderr, "posix_spawn() error=%d\n", err);
|
(void) fputs (_(MSG_NSCD_FLUSH_CACHE_FAILED), stderr);
|
||||||
|
(void) fprintf (stderr, "posix_spawn() error=%d\n", err);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Wait for the spawned process to exit */
|
/* Wait for the spawned process to exit */
|
||||||
termpid = TEMP_FAILURE_RETRY (waitpid (pid, &status, 0));
|
termpid = TEMP_FAILURE_RETRY (waitpid (pid, &status, 0));
|
||||||
if (termpid == -1)
|
if (-1 == termpid)
|
||||||
{
|
{
|
||||||
|
(void) fputs (_(MSG_NSCD_FLUSH_CACHE_FAILED), stderr);
|
||||||
perror("waitpid");
|
perror("waitpid");
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
else if (termpid != pid)
|
else if (termpid != pid)
|
||||||
{
|
{
|
||||||
fprintf(stderr, "waitpid returned %ld != %ld\n",
|
(void) fputs (_(MSG_NSCD_FLUSH_CACHE_FAILED), stderr);
|
||||||
|
(void) fprintf (stderr, "waitpid returned %ld != %ld\n",
|
||||||
(long int) termpid, (long int) pid);
|
(long int) termpid, (long int) pid);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user