/* Ficheros cabecera del sistema */ #include #include #include #include /* ficheros cabecera de la aplicacion */ #include "tipos_cola.h" #include "error_cola.h" main() { int ret, fd0, fd1; struct mensaje c; void err( int ); fd0 = msgget( BUZON0_ID, IPC_CREAT | 0666); if ( fd0 < 0 ) err( MS0_ERR ); ret = 0; do { ret = msgrcv( fd0, (struct msgbuf *)&c, DIM_MENSA0, TIPO0, 0); if ( ret < 0 ) { err( MS1_ERR ); break; } else { /* Es finalizacion? */ if ( !strcmp( c.mensaje, FIN_SERVIDOR ) ) break; /* Si no es finalizacion entonces se intenta ejecutar orden */ printf("COMANDO A EJECUTAR %s: \n",c.mensaje); ret = system( c.mensaje ); if ( ret < 0 ) err(MS4_ERR); } } while ( 1 ); /* Elimino colas de comunicacion */ if ( msgctl(fd0, IPC_RMID, (struct msqid_ds *)0) < 0 ) err(MS3_ERR); }