linux中的return问题 - Linux/Unix社区 / 程序开发区
有一段创建消息队列的代码如下:
int creat_msg_queue()
{
key_t key;
int proj_id;
int msqid;
struct msqid_ds buffer;
proj_id=2;
key=ftok("/home/program",proj_id);
if(key==-1){
perror("cannot generate the IPC key");
return -1;
}
msqid=msgget(key,IPC_CREAT | 0660);
if(msqid==-1){
perror("cannot create message queue resource");
return -1;
}
printf("msqid=%d\n",msqid);
return msqid;
}
在该函数中我打印出的“msqid”的数值是32769
但是该函数的返回值却是0,这是为什么啊?
32769的二进制码是1000000000000001正好是0的补码。不过我解释不了,标记等待高人
C/C++ code:
#include <stdio.h>
# include <sys/ipc.h>
#include <sys/types.h>
#include <sys/msg.h>
#include <unistd.h>
int creat_msg_queue()
{
key_t key;
int proj_id;
int msqid;
struct msqid_ds buffer;
proj_id=2;
key=ftok("/home/program",proj_id);
if(key==
相关问答:
两个文件1.PC,1.inc
1.PC有操作oracle数据库的 ,1.inc也有操作oracle数据库
在其他数据中如informix 中$include 1.inc就可以使用了
在ORACLE数据库重 $include 1.inc不可用 EXEC SQL include 1.inc也不可 ......
咨询QQ:269562808
bzip2recover
功能说明:用来修复损坏的.bz2文件。
语法:bzip2recover[.bz2压缩文件]
补充说明:bzip2是以区块的方式来压缩文件,每个区块视为独立的单位。因此,当某一区
块损坏时,便可利 ......
我的项目所在的环境是php+apache+linux
现我重启服务是 service httpd restart
现我想定时重启此项服务(定在每天下午4点) 怎么实现呀,多谢
crontab
* 16 * * * service httpd restart
学习 + d ......
大家好,我现在正在学习linux系统,碰到点问题想请问大家,希望前辈能够指教。
在linux中为什么我用shutdown -r now 命令来重启系统没有用呢,而reboot命令就可以。
另外我也试过#shutdown -r now 和
shutdow等命 ......
有一台服务器内存是8g,上面就跑了一个tomcat,其他什么都没有,tomcat设置了最大内存为1g,但是不知道怎么回事情内存使用的非常多。
[equitydev@szgeoweb1 ~]$ free -m
total used ......