Sponsored Content
Top Forums Programming Msgget(2) returns 0 - a workaround fix Post 302906955 by mr_bandit on Tuesday 24th of June 2014 07:15:20 PM
Old 06-24-2014
errno after msgget() returns 0

To be honest, I did not look at errno after msgget() returned 0 (It was in the wee early hours and I had bigger fish..). I will try that and get back with the results. This will also tell me if the original key returns 0.

The interesting thing is we loaded a *way* earlier version of the code to test a completely different thing. I jut did a ipcs and got

Code:
------ Message Queues --------
key        msqid      owner      perms      used-bytes   messages
0x000000f0 0          gfi        666        0            0

where you can see msgqid == 0 and the system seems to be performing happily (at least this part of it). This would seem to enforce the observation / theory that once the msgqid becomes 0, it stays 0. No complaints from msgsnd() or msgrcv().

So - this may be a brainfart on my part. After all, I did have another bug throwing a SIGSEGV at the same time. And it was very late/early. If it is a brainfart, my apologies.

Again, this an unpatched Ubuntu 8

@achenlehas an interesting suggestion. I had not thought of setting errno to a value before making the call. The question then becomes: why not set it to (-1)? errno values are positive, at least on Linux. (I seem to remember them being negative numbers on BSD 4.1, but that was a *long* time ago...)
 

9 More Discussions You Might Find Interesting

1. Programming

about msgget troble

hi,all i have in trouble about msgget. i create a queue and the program like blow: openMsg( pid_t key ) { .... int msgid; .... msgid=msgget(key,IPC_CREAT|IPC_EXCL|0666) if( msgid<=0 ){ fprintf( stdout,"%s,%d",strerror(errno),errno ); return -1; ... (9 Replies)
Discussion started by: subrain
9 Replies

2. Shell Programming and Scripting

find & sed -i work fine. Now need -i workaround for old OS.

I have a script that does a search and replace on a tree using find, xargs and sed that looks something like this. find . -type f -print0 | xargs -0 sed -i 's/fromthis/tothis/g' Now this works fine on new versions on Linux but I need to make the script work on an old RAQ550 that has an older... (3 Replies)
Discussion started by: simonb
3 Replies

3. Programming

Problem with msgget()

Hi, I am having problem with msgget() function. Here is the problem that I am having on Unix : I have two processes sender and receiver. Sender generates queue (msgget()) with some key e.g. 938, for output. Receiver reads from the same queue. i.e. receiver also tries to get queue... (2 Replies)
Discussion started by: Ashwini
2 Replies

4. UNIX for Dummies Questions & Answers

Workaround for macros in sftp command

Hi, I've some existing scripts wherein am using ftp + .netrc. I've defined my macros in .netrc file. I want to switch to sftp now but it seems it doesn't support macros and .netrc and it gives "command invalid" error. Is there any other alternative? Note: I don't want help for... (1 Reply)
Discussion started by: ps51517
1 Replies

5. Windows & DOS: Issues & Discussions

Samba trouble shoot / workaround ?

Hello, I've setup a ubuntu 10.04 server running samba 3.4.7 as domain controler / file server at a customer site, that works great most of the time but I face a random problem. Of course I'm never on the site when the problem occurs, so I cannot investigate in real time. What happens is that... (2 Replies)
Discussion started by: Manu.b
2 Replies

6. Shell Programming and Scripting

Calculation returns no value

#/bin/sh ..... #convert memory to MB let "mmsize_a= ($mmsize)/256" let "mminuse_a= ($mminuse)/256" let "mmfree_a= ($mmsize_a -$mminuse_a)" let "mmfreepercent= (($mmfree_a)/($mmsize_a))*100" # #format output echo "\n\n######################" >>$sndFile echo "\n$sysName Total Memory usage"... (3 Replies)
Discussion started by: Daniel Gate
3 Replies

7. Programming

msgget message queue always get permission denied

I want to use msgget() to obtain a message queue between two processes, here is my code: the first one create the mq, the second one open it and add a message to it. But when I execute the second one, I get permission denied. I've already desperately tried everything I can think of to solve this... (2 Replies)
Discussion started by: tefino
2 Replies

8. UNIX for Advanced & Expert Users

stuck in CLOSE_WAIT Solaris 10 - Patch and workaround

Solaris 10 Sparc: When you got a connection locking a tcp/port, and the status is CLOSE_WAIT (for ever :wall:), you just use the tcpdrop, to close the connection. This is a OS bug. I wrote the bug id bellow: BUG-ID 6468753 connections stuck in CLOSE_WAIT The patch that's correct the bug:... (0 Replies)
Discussion started by: thiagofborn
0 Replies

9. AIX

AIO workaround AIX 5.3 to AIX 7.1

Hello Folks, Facing a problem starting Apache Services on AIX 7.1 This is the error i'm getting /oraapp/prodora/iAS/Apache/Apache/bin/apachectl start: httpd started Syntax error on line 17 of /oraapp/prodora/iAS/Apache/modplsql/cfg/plsql_pls.conf: Cannot load... (0 Replies)
Discussion started by: filosophizer
0 Replies
msgget(2)							   System Calls 							 msgget(2)

NAME
msgget - get message queue SYNOPSIS
#include <sys/msg.h> int msgget(key_t key, int msgflg); DESCRIPTION
The msgget() argument returns the message queue identifier associated with key. A message queue identifier and associated message queue and data structure (see Intro(2)) are created for key if one of the following are true: o key is IPC_PRIVATE. o key does not already have a message queue identifier associated with it, and (msgflg&IPC_CREAT) is true. On creation, the data structure associated with the new message queue identifier is initialized as follows: o msg_perm.cuid, msg_perm.uid, msg_perm.cgid, and msg_perm.gid are set to the effective user ID and effective group ID, respec- tively, of the calling process. o The low-order 9 bits of msg_perm.mode are set to the low-order 9 bits of msgflg. o msg_qnum, msg_lspid, msg_lrpid, msg_stime, and msg_rtime are set to 0. o msg_ctime is set to the current time. o msg_qbytes is set to the system limit. See NOTES. RETURN VALUES
Upon successful completion, a non-negative integer representing a message queue identifier is returned. Otherwise, -1 is returned and errno is set to indicate the error. ERRORS
The msgget() function will fail if: EACCES A message queue identifier exists for key, but operation permission (see Intro(2)) as specified by the low-order 9 bits of msgflg would not be granted. EEXIST A message queue identifier exists for key but (msgflg&IPC_CREAT) and (msgflg&IPC_EXCL) are both true. ENOENT A message queue identifier does not exist for key and (msgflg&IPC_CREAT) is false. ENOSPC A message queue identifier is to be created but the system-imposed limit on the maximum number of allowed message queue identi- fiers system wide would be exceeded. See NOTES. ATTRIBUTES
See attributes(5) for descriptions of the following attributes: +-----------------------------+-----------------------------+ | ATTRIBUTE TYPE | ATTRIBUTE VALUE | +-----------------------------+-----------------------------+ |Interface Stability |Standard | +-----------------------------+-----------------------------+ SEE ALSO
rctladm(1M), Intro(2), msgctl(2), msgrcv(2), msgsnd(2), setrctl(2), ftok(3C), attributes(5), standards(5) NOTES
The system-defined limit used to initialize msg_qbytes is the minimum enforced value of the calling process's process.max-msg-qbytes resource control. The system-imposed limit on the number of message queue identifiers is maintained on a per-project basis using the project.max-msg-ids resource control. The zone.max-msg-ids resource control restricts the total amount of message queue identifiers that can be allocated by a zone. See rctladm(1M) and setrctl(2) for information about using resource controls. SunOS 5.11 14 Aug 2006 msgget(2)
All times are GMT -4. The time now is 09:07 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy