/**
*
* @File : exo_01d.cxx
*
* @Authors : D. Mathieu, M. Laporte
*
* @Date : 06/11/2001
*
* @Version : V1.0
*
* @Synopsis : démon qui gère la file de messages
*
**/
#include <string>
#include <exception>
#include <csignal> // SIGUSR1, SIG_IGN
#include <unistd.h> // pause(), getuid()
#include <sys/ipc.h> // IPC_CREAT, IPC_EXCL
#include "CException.h"
#include "Reveil.h"
#include "nsSysteme.h" // Signal(), Fork(), Msgget(), Msgctl()
#include "CstCodErr.h"
#include "SaveSig.h"
using namespace nsSysteme;
using namespace nsUtil; // Reveil(), CException
namespace { void Derout (int) {} }
int std::ppal (int argc, char * argv []) throw (exception)
{
if (argc != 1)
throw CException (string ("Usage :") + argv [0], CstExcArg);
SaveSig (SIG_IGN);
Signal (SIGUSR1, Derout);
if (Fork()) return 0;
int MsqId = Msgget (::getuid (), IPC_CREAT | IPC_EXCL | 0700);
Reveil (SIGUSR1);
::pause ();
Msgctl (MsqId);
return 0;
} // ppal()