int
main(int argc, char **argv)
{
	int				msqid;
	struct msqid_ds	info;
	struct msgbuf	buf;

	msqid = Msgget(IPC_PRIVATE, SVMSG_MODE | IPC_CREAT);

	buf.mtype = 1;
	buf.mtext[0] = 1;
	Msgsnd(msqid, &buf, 1, 0);

	Msgctl(msqid, IPC_STAT, &info);
	printf("read-write: %03o, cbytes = %lu, qnum = %lu, qbytes = %lu\n",
		   info.msg_perm.mode & 0777, (unsigned long int) info.msg_cbytes,
		   (unsigned long int ) info.msg_qnum, (unsigned long int) info.msg_qbytes);

	int ret = system("ipcs -q");
    if( ret == -1){
        perror("system\n");
        printf("Error in system call\n");
    }

	Msgctl(msqid, IPC_RMID, NULL);
	exit(0);
}
Esempio n. 2
0
int Snd(int dest, void *structure, int size) {
	
	dest = Msgget(dest, 0);
	if (dest == -1) {
		return -1;
	}
	
	Printf2("Sending special message to %d", dest);
	return Msgsnd(dest, structure, size, 0);
}
Esempio n. 3
0
/* include bw_svmsg2 */
void
writer(int contfd, int msqid)
{
	int		ntowrite;

	for ( ; ; ) {
		Read(contfd, &ntowrite, sizeof(ntowrite));

		while (ntowrite > 0) {
			Msgsnd(msqid, buf, xfersize - sizeof(long), 0);
			ntowrite -= xfersize;
		}
	}
}
Esempio n. 4
0
int SndCompactMessage(int dest, type_t type, int value, int id) {
	
	Printf2("Sending compact message to %d of type %ld", dest, type);
	
	dest = Msgget(dest, 0);
	if (dest == -1) {
		return -1;
	}
	CLEAR(compactMessage);
	compactMessage.type = type;
	compactMessage.content.value = value;
	compactMessage.content.id = (id == -1) ? GetMessageID() : id;

	return Msgsnd(dest, &compactMessage, sizeof(compactMessage), 0);
}
Esempio n. 5
0
int main(int argc, char **argv)
{
	int msqid;
	struct msqid_ds info;
	struct msgbuf buf;

	msqid = Msgget(IPC_PRIVATE, IPC_CREAT | SVMSG_MODE);

	buf.mtype = 1;
	buf.mtext[0] = 1;
	Msgsnd(msqid, &buf, 1, 0);

	Msgctl(msqid, IPC_STAT, &info);
	printf("read-write: %03o, cbytes = %lu, qnum = %lu, qbytes = %lu\n", info.msg_perm.mode & 0777, (ulong) info.msg_cbytes, (ulong) info.msg_qnum, (ulong) info.msg_qbytes);

	system("ipcs -q");

	Msgctl(msqid, IPC_RMID, NULL);
	exit(0);
}
Esempio n. 6
0
int main(int argc, char **argv)
{
	int mqid;
	size_t len;
	long type;
	struct msgbuf *ptr;

	if (argc != 4)
		err_quit("Usage: msgsnd <pathname> <#bytes> <type>");
	len = atoi(argv[2]);
	type = atoi(argv[3]);

	mqid = Msgget(Ftok(argv[1], 0), MSG_W);

	ptr = (struct msgbuf *)Calloc(sizeof(long) + len, sizeof(char));
	ptr->mtype = type;

	Msgsnd(mqid, ptr, len, 0);

	exit(0);
}