IPC:system V消息队列

2023-05-16

ftok函数 

ftok - convert a pathname and a project identifier to a System V IPC key
SYNOPSIS
       #include <sys/types.h>
       #include <sys/ipc.h>

       key_t ftok(const char *pathname, int proj_id);

DESCRIPTION
       The  ftok()  function  uses  the identity of the file named by the given pathname
       (which must refer to an existing, accessible file) and the  least  significant  8
       bits  of  proj_id  (which  must be nonzero) to generate a key_t type System V IPC
       key, suitable for use with msgget(2), semget(2), or shmget(2).

       The resulting value is the same for all pathnames that name the same  file,  when
       the  same  value of proj_id is used.  The value returned should be different when
       the (simultaneously existing) files or the project IDs differ.

RETURN VALUE
       On success, the generated key_t value is returned.  On failure  -1  is  returned,
       with errno indicating the error as for the stat(2) system call.

ATTRIBUTES
       For an explanation of the terms used in this section, see attributes(7).

 测试一:生成一个键值:

#include <iostream>
#include <unistd.h>
#include <stdlib.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <string.h>
#include <stdio.h>
#include <stdint.h>
#include <linux/limits.h>
#include <fcntl.h>
#include <sys/ipc.h>

#define DEBUG_INFO(format, ...) printf("%s:%d -- " format "\n", __func__, __LINE__,##__VA_ARGS__)
using namespace std;

struct mymsg{
    long mtype;
    int len;
    int frame_size;
    int frame_index;
    int frame_count;
    int offset;
    int length;
    char buf[PIPE_BUF];
    uint32_t crc;
};

int main(int argc, char **argv)
{
    system("mkdir /home/lkmao/test/msg/ -p");
    key_t key = ftok("/home/lkmao/test/msg/",'a');
    if(key == -1){
        perror("ftok");
        exit(-1);
    }
    DEBUG_INFO("%d %x",key,key);
    system("ls -lsh /home/lkmao/test/msg/");
    DEBUG_INFO("msg queue test");
    return 0;
}

测试结果:

main:36 -- 1627471003 61013c9b
总用量 0
main:38 -- msg queue test

msgget()函数

NAME
       msgget - get a System V message queue identifier

SYNOPSIS
       #include <sys/types.h>
       #include <sys/ipc.h>
       #include <sys/msg.h>

       int msgget(key_t key, int msgflg);

msgsnd()函数和msgrcv

NAME
       msgrcv, msgsnd - System V message queue operations

SYNOPSIS
       #include <sys/types.h>
       #include <sys/ipc.h>
       #include <sys/msg.h>

       int msgsnd(int msqid, const void *msgp, size_t msgsz, int msgflg);

       ssize_t msgrcv(int msqid, void *msgp, size_t msgsz, long msgtyp,
                      int msgflg);

 

 

 

 

测试二,子进程发消息,父进程接收消息

#include <iostream>
#include <unistd.h>
#include <stdlib.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <string.h>
#include <stdio.h>
#include <stdint.h>
#include <linux/limits.h>
#include <fcntl.h>
#include <sys/ipc.h>
#include <sys/msg.h>

#define DEBUG_INFO(format, ...) printf("%s:%d -- " format "\n", __func__, __LINE__,##__VA_ARGS__)
using namespace std;

struct mymsg{
    long mtype;
    int len;
    int frame_size;
    int frame_index;
    int frame_count;
    int offset;
    int length;
    char buf[PIPE_BUF];
    uint32_t crc;
};

int main(int argc, char **argv)
{
    system("rm -rf /home/lkmao/test/msg/");
    system("mkdir /home/lkmao/test/msg/ -p");
    key_t key = ftok("/home/lkmao/test/msg/",'a');
    if(key == -1){
        perror("ftok");
        exit(-1);
    }
    DEBUG_INFO("key %d %x",key,key);
    system("ls -lsah /home/lkmao/test/msg/");

    //msgget(key,IPC_CREAT | IPC_EXCL);//不存在则创建,IPC_CREAT加IPC_EXCL以后表表示存在则报错
    //int msg_id = msgget(key,IPC_CREAT);//大于0的32位整数:视参数msgflg来确定操作。通常要求此值来源于ftok返回的IPC键值
    int msg_id = msgget(IPC_PRIVATE,IPC_CREAT | 0666);//0(IPC_PRIVATE):会建立新的消息队列
    if(msg_id == -1){
        perror("msgget");
        exit(-1);
    }
    DEBUG_INFO("msg_id = %d %x",msg_id,msg_id);
    system("ls -lsh /home/lkmao/test/msg/");

    pid_t pid = fork();
    if(pid == -1){
        perror("fork");
        exit(-1);
    }
    if(pid == 0){
        struct mymsg *pmsg = (struct mymsg*)malloc(sizeof(struct mymsg));
        pmsg->mtype = 0x1001;
        pmsg->crc = 0x2001;
        //msgsnd(msg_id,pmsg,sizeof(struct mymsg) - sizeof(long),IPC_NOWAIT); //不阻塞
        int ret = msgsnd(msg_id,pmsg,sizeof(struct mymsg) - sizeof(long),0);//阻塞
        if(ret == -1){
            perror("msgsnd");
            free(pmsg);
            exit(-1);
        }
        DEBUG_INFO("ret = %d",ret);
        sleep(1);
        free(pmsg);
    }
    if(pid > 0){
        sleep(2);
        struct mymsg *pmsg = (struct mymsg*)malloc(sizeof(struct mymsg));
        //pmsg->mtype = 0x1001;
        //int ret = msgrcv(msg_id,pmsg,sizeof(struct mymsg) - sizeof(long),0x1001,0);
        int ret = msgrcv(msg_id,pmsg,sizeof(struct mymsg) - sizeof(long),0,0);
        if(ret == -1){
            perror("msgrcv");
            free(pmsg);
            exit(-1);
        }
        DEBUG_INFO("msgrcv:%x,%x,",pmsg->mtype,pmsg->crc);
        free(pmsg);
    }

    DEBUG_INFO("msg queue test finish");
    return 0;
}

测试结果:

main:38 -- key 1627471003 61013c9b
总用量 8.0K
4.0K drwxrwxr-x  2 lkmao lkmao 4.0K 5月   8 15:37 .
4.0K drwxrwxr-x 12 lkmao lkmao 4.0K 5月   8 15:37 ..
main:48 -- msg_id = 196614 30006
总用量 0
main:66 -- ret = 0
main:83 -- msg queue test
main:78 -- msgrcv:1001,2001,
main:83 -- msg queue test

msgctl函数

NAME
       msgctl - System V message control operations

SYNOPSIS
       #include <sys/types.h>
       #include <sys/ipc.h>
       #include <sys/msg.h>

       int msgctl(int msqid, int cmd, struct msqid_ds *buf);

msqid_ds结构体:

            struct msqid_ds {
               struct ipc_perm msg_perm;     /* Ownership and permissions */
               time_t          msg_stime;    /* Time of last msgsnd(2) */
               time_t          msg_rtime;    /* Time of last msgrcv(2) */
               time_t          msg_ctime;    /* Time of last change */
               unsigned long   __msg_cbytes; /* Current number of bytes in
                                                queue (nonstandard) */
               msgqnum_t       msg_qnum;     /* Current number of messages
                                                in queue */
               msglen_t        msg_qbytes;   /* Maximum number of bytes
                                                allowed in queue */
               pid_t           msg_lspid;    /* PID of last msgsnd(2) */
               pid_t           msg_lrpid;    /* PID of last msgrcv(2) */
           };

 struct ipc_perm

            struct ipc_perm {
               key_t          __key;       /* Key supplied to msgget(2) */
               uid_t          uid;         /* Effective UID of owner */
               gid_t          gid;         /* Effective GID of owner */
               uid_t          cuid;        /* Effective UID of creator */
               gid_t          cgid;        /* Effective GID of creator */
               unsigned short mode;        /* Permissions */
               unsigned short __seq;       /* Sequence number */
           };

测试代码:获取msgget之后、msgsnd之后、msgrcv之后的消息的属性。

#include <iostream>
#include <unistd.h>
#include <stdlib.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <string.h>
#include <stdio.h>
#include <stdint.h>
#include <linux/limits.h>
#include <fcntl.h>
#include <sys/ipc.h>
#include <sys/msg.h>

#define DEBUG_INFO(format, ...) printf("%s:%d -- " format "\n", __func__, __LINE__,##__VA_ARGS__)
using namespace std;

struct mymsg{
    long mtype;
    int len;
    int frame_size;
    int frame_index;
    int frame_count;
    int offset;
    int length;
    char buf[PIPE_BUF];
    uint32_t crc;
};

void show_msg_queue_attr(int msg_id,struct msqid_ds *pmsg_info){
    int ret = -1;
    struct msqid_ds msg_info;
    ret = msgctl(msg_id,IPC_STAT,&msg_info);
    if(ret == -1){
        perror("msgctl IPC_STAT");
        exit(-1);
    }
    
    DEBUG_INFO("%ld",msg_info.msg_cbytes);
    DEBUG_INFO("%d",msg_info.msg_qnum);

    DEBUG_INFO("%d",msg_info.msg_qbytes);
    DEBUG_INFO("%d",msg_info.msg_lspid);
    DEBUG_INFO("%d",msg_info.msg_lrpid);

    DEBUG_INFO("%s",ctime(&msg_info.msg_stime));
    DEBUG_INFO("%s",ctime(&msg_info.msg_rtime));
    DEBUG_INFO("%s",ctime(&msg_info.msg_ctime));

    DEBUG_INFO("%d",msg_info.msg_perm.uid);
     DEBUG_INFO("%d",msg_info.msg_perm.gid);
     if(pmsg_info != NULL){
        memcpy(pmsg_info,&msg_info,sizeof(msg_info));
     }

}

int main(int argc, char **argv)
{
    system("rm -rf /home/lkmao/test/msg/");
    system("mkdir /home/lkmao/test/msg/ -p");
    key_t key = ftok("/home/lkmao/test/msg/",'a');
    if(key == -1){
        perror("ftok");
        exit(-1);
    }
    DEBUG_INFO("key %d %x",key,key);
    system("ls -lsah /home/lkmao/test/msg/");

    //msgget(key,IPC_CREAT | IPC_EXCL);//不存在则创建,IPC_CREAT加IPC_EXCL以后表表示存在则报错
    //int msg_id = msgget(key,IPC_CREAT);//大于0的32位整数:视参数msgflg来确定操作。通常要求此值来源于ftok返回的IPC键值
    int msg_id = msgget(IPC_PRIVATE,IPC_CREAT | 0666);//0(IPC_PRIVATE):会建立新的消息队列
    if(msg_id == -1){
        perror("msgget");
        exit(-1);
    }
    show_msg_queue_attr(msg_id,NULL);
    DEBUG_INFO("msg_id = %d %x",msg_id,msg_id);
    system("ls -lsh /home/lkmao/test/msg/");

    pid_t pid = fork();
    if(pid == -1){
        perror("fork");
        exit(-1);
    }
    if(pid == 0){
        struct mymsg *pmsg = (struct mymsg*)malloc(sizeof(struct mymsg));
        pmsg->mtype = 0x1001;
        pmsg->crc = 0x2001;
        //msgsnd(msg_id,pmsg,sizeof(struct mymsg) - sizeof(long),IPC_NOWAIT); //不阻塞
        int ret = msgsnd(msg_id,pmsg,sizeof(struct mymsg) - sizeof(long),0);//阻塞
        if(ret == -1){
            perror("msgsnd");
            free(pmsg);
            exit(-1);
        }
        DEBUG_INFO("ret = %d",ret);
        show_msg_queue_attr(msg_id,NULL);
        sleep(1);
        free(pmsg);
    }
    if(pid > 0){
        sleep(2);
        struct mymsg *pmsg = (struct mymsg*)malloc(sizeof(struct mymsg));
        //pmsg->mtype = 0x1001;
        //int ret = msgrcv(msg_id,pmsg,sizeof(struct mymsg) - sizeof(long),0x1001,0);
        int ret = msgrcv(msg_id,pmsg,sizeof(struct mymsg) - sizeof(long),0,0);
        if(ret == -1){
            perror("msgrcv");
            free(pmsg);
            exit(-1);
        }
        show_msg_queue_attr(msg_id,NULL);
        DEBUG_INFO("msgrcv:%x,%x,",pmsg->mtype,pmsg->crc);
        free(pmsg);
    }

    DEBUG_INFO("msg queue test finish");
    return 0;
}

输出结果:

main:66 -- key 1627471003 61013c9b
总用量 8.0K
4.0K drwxrwxr-x  2 lkmao lkmao 4.0K 5月   8 16:06 .
4.0K drwxrwxr-x 12 lkmao lkmao 4.0K 5月   8 16:06 ..
show_msg_queue_attr:38 -- 0
show_msg_queue_attr:39 -- 0
show_msg_queue_attr:41 -- 16384
show_msg_queue_attr:42 -- 0
show_msg_queue_attr:43 -- 0
show_msg_queue_attr:45 -- Thu Jan  1 08:00:00 1970

show_msg_queue_attr:46 -- Thu Jan  1 08:00:00 1970

show_msg_queue_attr:47 -- Mon May  8 16:06:54 2023

show_msg_queue_attr:49 -- 1000
show_msg_queue_attr:50 -- 1000
main:77 -- msg_id = 360459 5800b
总用量 0
main:96 -- ret = 0
show_msg_queue_attr:38 -- 4128
show_msg_queue_attr:39 -- 1
show_msg_queue_attr:41 -- 16384
show_msg_queue_attr:42 -- 56349
show_msg_queue_attr:43 -- 0
show_msg_queue_attr:45 -- Mon May  8 16:06:54 2023

show_msg_queue_attr:46 -- Thu Jan  1 08:00:00 1970

show_msg_queue_attr:47 -- Mon May  8 16:06:54 2023

show_msg_queue_attr:49 -- 1000
show_msg_queue_attr:50 -- 1000
main:117 -- msg queue test finish
show_msg_queue_attr:38 -- 0
show_msg_queue_attr:39 -- 0
show_msg_queue_attr:41 -- 16384
show_msg_queue_attr:42 -- 56349
show_msg_queue_attr:43 -- 56340
show_msg_queue_attr:45 -- Mon May  8 16:06:54 2023

show_msg_queue_attr:46 -- Mon May  8 16:06:56 2023

show_msg_queue_attr:47 -- Mon May  8 16:06:54 2023

show_msg_queue_attr:49 -- 1000
show_msg_queue_attr:50 -- 1000
main:113 -- msgrcv:1001,2001,
main:117 -- msg queue test finish

删除消息队列IPC_RMID

测试三,删除测试。

#include <iostream>
#include <unistd.h>
#include <stdlib.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <string.h>
#include <stdio.h>
#include <stdint.h>
#include <linux/limits.h>
#include <fcntl.h>
#include <sys/ipc.h>
#include <sys/msg.h>

#define DEBUG_INFO(format, ...) printf("%s:%d -- " format "\n", __func__, __LINE__,##__VA_ARGS__)
using namespace std;

struct mymsg{
    long mtype;
    int len;
    int frame_size;
    int frame_index;
    int frame_count;
    int offset;
    int length;
    char buf[PIPE_BUF];
    uint32_t crc;
};

void show_msg_queue_attr(int msg_id,struct msqid_ds *pmsg_info){
    int ret = -1;
    struct msqid_ds msg_info;
    ret = msgctl(msg_id,IPC_STAT,&msg_info);
    if(ret == -1){
        perror("msgctl IPC_STAT");
        exit(-1);
    }
    
    DEBUG_INFO("%ld",msg_info.msg_cbytes);
    DEBUG_INFO("%d",msg_info.msg_qnum);

    DEBUG_INFO("%d",msg_info.msg_qbytes);
    DEBUG_INFO("%d",msg_info.msg_lspid);
    DEBUG_INFO("%d",msg_info.msg_lrpid);

    DEBUG_INFO("%s",ctime(&msg_info.msg_stime));
    DEBUG_INFO("%s",ctime(&msg_info.msg_rtime));
    DEBUG_INFO("%s",ctime(&msg_info.msg_ctime));

    DEBUG_INFO("%d",msg_info.msg_perm.uid);
     DEBUG_INFO("%d",msg_info.msg_perm.gid);
     if(pmsg_info != NULL){
        memcpy(pmsg_info,&msg_info,sizeof(msg_info));
     }

}

int main(int argc, char **argv)
{
    system("rm -rf /home/lkmao/test/msg/");
    system("mkdir /home/lkmao/test/msg/ -p");
    key_t key = ftok("/home/lkmao/test/msg/",'a');
    if(key == -1){
        perror("ftok");
        exit(-1);
    }
    DEBUG_INFO("key %d %x",key,key);
    system("ls -lsah /home/lkmao/test/msg/");

    //msgget(key,IPC_CREAT | IPC_EXCL);//不存在则创建,IPC_CREAT加IPC_EXCL以后表表示存在则报错
    int msg_id = msgget(key,IPC_CREAT | 0666);//大于0的32位整数:视参数msgflg来确定操作。通常要求此值来源于ftok返回的IPC键值
    //int msg_id = msgget(IPC_PRIVATE,IPC_CREAT | 0666);//0(IPC_PRIVATE):会建立新的消息队列
    if(msg_id == -1){
        perror("msgget");
        exit(-1);
    }
    struct msqid_ds msg_info;
    show_msg_queue_attr(msg_id,&msg_info);

    int ret = msgget(key,IPC_CREAT | IPC_EXCL | 0666);
    if(ret == -1){
        perror("msgget");
        DEBUG_INFO("delete msg");
        if(msgctl(msg_id,IPC_RMID,&msg_info) == 0){
            DEBUG_INFO("delete msg ok");
        }
    }else{

    }

    ret = msgget(key,IPC_CREAT | IPC_EXCL | 0666);
    if(ret == -1){
        perror("msgget");
        msgctl(msg_id,IPC_RMID,&msg_info);
    }else{
        DEBUG_INFO("msgget ok = %d",msg_id);
    }
    
    DEBUG_INFO("msg queue test finish");
    return 0;
}

测试结果:

main:66 -- key 1627471003 61013c9b
总用量 8.0K
4.0K drwxrwxr-x  2 lkmao lkmao 4.0K 5月   8 16:30 .
4.0K drwxrwxr-x 12 lkmao lkmao 4.0K 5月   8 16:30 ..
show_msg_queue_attr:38 -- 0
show_msg_queue_attr:39 -- 0
show_msg_queue_attr:41 -- 16384
show_msg_queue_attr:42 -- 0
show_msg_queue_attr:43 -- 0
show_msg_queue_attr:45 -- Thu Jan  1 08:00:00 1970

show_msg_queue_attr:46 -- Thu Jan  1 08:00:00 1970

show_msg_queue_attr:47 -- Mon May  8 16:29:33 2023

show_msg_queue_attr:49 -- 1000
show_msg_queue_attr:50 -- 1000
msgget: File exists
main:82 -- delete msg
main:84 -- delete msg ok
main:95 -- msgget ok = 65536
main:98 -- msg queue test finish

IPC_SET

小结

本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

IPC:system V消息队列 的相关文章

  • IPC 的共享内存和线程的共享内存有什么区别?

    让我们使用 POSIX 共享内存 例如 shmget 协调进程间通信的常见调用 调用 shmget 并协调共享内存段上的通信与 Linux 在单个进程中实现共享内存和线程之间的同步有何不同 其中之一更轻吗 SHM适用于多进程中的IPC 在现
  • NamedPipe 多个服务器

    对于简单的 IPC 我选择了 NamedPipes 在进程 本地 之间进行通信 由于需求的变化 应该有多个服务器实例 这会导致同一管道名上有多个 侦听器 但似乎有一个问题 这些侦听器中只有一个会收到消息 其他所有实例都不会收到消息 有某种
  • 如果系统命令/反引号中的脚本失败,则主脚本需要退出状态!=0

    Code of inter pl is use strict use warnings my var1 cat gra def ment ckfile txt ckfile txt doesn t exist print Hello Wor
  • AF_UNIX 相当于 Windows [重复]

    这个问题在这里已经有答案了 我想知道如何在 Windows 上使用类似于 Unix Domain Socket 的功能 行为是 一个进程将成为 服务器 并接收来自其他进程的连接 并且它可以保留和使用来自不同进程的连接 就像 TCP 套接字一
  • 与修改后的 python 解释器进行进程间通信

    TL DR 当 stdin stdout 不可用时 如何生成不同的 python 解释器 从 python 内部 并在父级和子级之间创建通信通道 我希望我的 python 脚本执行修改后的Python解释器并通过某种IPC 例如multip
  • PHP 系统() 参数

    我有以下代码执行C 程序 and 输出它 div div 我怎样才能做到这一点您可以将参数传递给 c 程序 这样说 如果这是c program include
  • unlink 和 rm 在 unix 上的区别

    这两个命令之间真正的区别是什么 为什么删除文件的系统调用叫unlink代替delete 你需要了解一些关于原始 Unix 文件系统的知识才能理解这个非常重要的问题 与同时代的其他操作系统 60 年代末 70 年代初 不同 Unix 没有将文
  • System.setProperty("sun.net.http.allowRestrictedHeaders", "true") 在詹金斯中不起作用

    我正在尝试在 http 请求标头中发送原始标头 但是当我获取其值时 我得到的是 null 而不是我在原始标头中设置的 url 另外 我还使用以下命令启用了受限标头作为詹金斯作业中请求标头的一部分发送 System setProperty s
  • Android IPC远程服务调用显示错误

    我想做一个关于IPC通信 服务之间的通信 的演示应用程序 我在用AIDL为了那个原因 我发现大部分教程RemoteService和客户端在同一个包中 我实际上是分开做的 同时传递我正在使用的对象Parcelable方法和面临的错误 它说就像
  • 使用AppService的连接持续时间有限制吗?

    我有一个 UWP 应用程序托管应用服务 https learn microsoft com en us windows uwp launch resume how to create and consume an app service在同
  • 使用 WM_COPYDATA 在进程之间发送数据

    我希望在进程之间发送文本 我发现了很多这样的例子 但没有一个我可以工作 这是我到目前为止所拥有的 对于发送部分 COPYDATASTRUCT CDS CDS dwData 1 CDS cbData 8 CDS lpData NULL Sen
  • 将命令行参数传递给已运行的应用程序实例

    我想将应用程序新实例的命令行参数传递给已经运行的应用程序 如果存在 到目前为止 我已经尝试了以下方法 程序 cs string Arguments Environment GetCommandLineArgs int iCurrentPro
  • 从一个 Nodejs 应用程序调用另一个 Nodejs 应用程序中的 API 的方法

    我们的应用程序将有一个网站和一个移动应用程序 两者都与同一个 API 后端进行通信 我有一个仅提供 API 服务的 Nodejs 应用程序 还有一个为网站提供 html 页面服务的 Nodejs 应用程序 我正在为这两个应用程序使用 Exp
  • 在 C# 中进行进程间通信 (IPC) 最简单的方法是什么? [关闭]

    Closed 这个问题是基于意见的 help closed questions 目前不接受答案 我有两个 C 应用程序 我希望其中一个向另一个发送两个整数 这不必很快 因为它每隔几秒调用一次 做到这一点最简单的方法是什么 它不一定是最优雅的
  • 从 createProcess 外部获取的句柄读取

    我正在尝试创建一个进程 并通过我在外部提供的句柄与其进行通信createProcess功能 stdOutH lt openFile logDir gt stdout log ReadWriteMode hSetBuffering stdOu
  • Haskell 类型系统的细微差别

    我一直在深入了解 haskell 类型系统的本质 并试图了解类型类的要点 我已经学到了很多东西 但我在下面的代码片段上遇到了困难 使用这些类和实例定义 class Show a gt C a where f Int gt a instanc
  • Python:无法使用 os.system() 打开文件

    我正在编写一个使用该应用程序的 Python 脚本pdftk http www pdflabs com tools pdftk the pdf toolkit 几次来执行某些操作 例如 我可以在 Windows 命令行 shell 中使用
  • 如何使用应用程序接口将蓝牙套接字传递给另一个活动

    因此 根据我收集的信息 套接字连接既不可序列化 也不可分割 但我需要将蓝牙连接传递给另一个活动 我不想作为中间人编写服务 所以请不要将此作为解决方案发布 我听说有一种方法可以使用自定义应用程序接口来传递这些类型的对象 但我一生都找不到这样的
  • 等待进程直到所有子进程完成? [复制]

    这个问题在这里已经有答案了 我有一个创建两个或更多子进程的主进程 我希望主进程等待所有子进程完成其操作并退出 main script py p1 subprocess Popen python script1 py p2 subproces
  • Zuul不转发请求到其他微服务

    我正在使用 Spring Boot 微服务 我已经配置了 eureka zuul 代理和另一个微服务 帐户 如果我直接从帐户拨打电话 则工作正常 帐户和 zuul 服务器都显示在 eureka 上 当我尝试使用 zuul 代理进行访问时 它

随机推荐

  • UDP服务器端和客户端程序设计

    实验三 UDP服务器端程序设计 一 实验目的 学习和掌握Linux下的UDP服务器基本原理和基本编程方法 xff0c 体会与TCP的区别 xff0c TCP编程 xff1a http blog csdn net yueguanghaidao
  • python实现的文本编辑器

    wxpython实现的文本编辑器 效果如下 xff1a 主要功能 xff1a 1 编辑保存文本 xff0c 打开修改文本 2 常用快捷键 xff0c 复制 xff0c 粘贴 xff0c 全选等 3 支持撤销功能 4 支持弹出式菜单 代码如下
  • C语言开发Linux下web服务器(支持GET/POST,SSL,目录显示等)

    这个主要是在CSAPP基础上做的 xff0c 添加了POST xff0c SSL xff0c 目录显示等功能 一 实现功能 xff1a 1 支持GET POST方法 2 支持SSL安全连接即HTTPS 3 支持CGI 4 基于IP地址和掩码
  • sklearn2pmml xgboost缺失值(missing)处理的坑

    sklearn2pmml xgboost缺失值 missing 处理的坑 今天同事在部署xgboost pmml模型时遇到了大坑 xff0c 线上spark预测和本地python预测结果怎么都不对应 xff0c 记录一下处理过程 看了下同事
  • adb导出手机应用到电脑

    简单说一下相关步骤 xff0c 以备不时之需 1 手机开启usb调试 2 Windows系统 Win 43 R打开命令行窗口 xff0c 输入adb devices xff0c 如果连接成功会出现机子的序列号 3 adb shell pm
  • Js作用域与作用域链详解

    一直对Js的作用域有点迷糊 xff0c 今天偶然读到Javascript权威指南 xff0c 立马被吸引住了 xff0c 写的真不错 我看的是第六版本 xff0c 相当的厚 xff0c 大概1000多页 xff0c Js博大精深 xff0c
  • windows10环境下tensorflow安装教程

    楼主最近一直忙着找工作 最近几个月一直all in java 好久没学机器学习 深度学习 前几天突然通知要提交论文中期了 于是赶紧打开电脑 结果发现之前安装的tensorflow居然登陆不上了 折腾了半天 搜过各种csdn博客 一直安装失败
  • 'gbk' codec can't encode character '\xa0'

    从网上抓了一些字节流 xff0c 想打印出来结果发生了一下错误 xff1a UnicodeEncodeError 39 gbk 39 codec can 39 t encode character 39 xbb 39 in position
  • 【Git记录学习】github创建项目以及本地使用(vscode)

    一 github创建空仓库 从github中创建空仓库 在执行完上一步操作后会返回这样的界面 xff0c 包括了一些基本的git操作以及HttpS SSH地址 生成一个readme md文档 xff08 步骤2 Set up下面有蓝色的超链
  • 关于DFT变换含义、公式和具体形式

    原文地址 xff1a http blog sina com cn s blog 7853c3910102v9wd html 这篇文章从实际工程应用的角度 xff0c 记录一下如何计算 xff0c 关于公式 变形和应用 维基百科上的 DFT公
  • 1602显示数字不稳定一直跳动(AD转换)

    程序如下所示 首先说明下 xff0c 此程序为AD转换芯片PCF8591采集电压数据 xff0c 然后送到1602显示 现象 xff1a 1602显示的数字一直频繁的跳动 xff0c 乱花眼 此现象不是一直出现的 xff0c 有时候会出现
  • C++11中的线程类

    前面介绍的线程是利用了POSIX线程库 xff0c 这是传统C C 43 43 程序员使用线程的方式 xff0c 而C 43 43 11提供了语言层面使用线程的方式 C 43 43 11新标准中引入了5个头文件来支持多线程编程 xff0c
  • 4.4.1内核编译

    内核源码下载地址 xff1a https mirrors edge kernel org pub linux kernel v4 x linux 4 4 1 tar gz 安装依赖包 xff1a 报错就装 cp boot config xx
  • fatal error: hugetlbfs.h: No such file or directory

    fatal error hugetlbfs h No such file or directory 解决办法 xff1a sudo apt get update sudo apt get install libhugetlbfs dev
  • WSL下 配置NFS-失败

    配置一个IP地址 xff1a sudo ip addr add 192 168 250 2 24 broadcast 192 168 250 255 dev eth2 sudo apt get install nfs kernel serv
  • OMT 对象模型、动态模型和功能模型

    对象模型描述系统中对象的静态结构 对象之间的关系 对象的属性 对象的操作 对象模型表示静态的 结构上的 系统的 数据 34 特征 对象模型为动态模型和功能模型提供了基本的框架 xff0c 对象模型用包含对象和类的对象图来表示 OMT的对象模
  • 关于epoll的调试的几个问题

    将今天调试的几个小问题点总结下 xff0c 后续遇到再添加 一 将总结的问题点放在最前面 1 epoll wait的maxevents参数 epoll wait的maxevents参数 xff0c 经过测试 xff0c maxevents的
  • poll函数测试

    一 基础知识 include lt poll h gt int poll struct pollfd fds nfds t nfds int timeout 其中参数fds指向一个结构体数组的第0个元素的指针 xff0c 每个数组元素都是一
  • IPC:匿名管道和命名管道

    一 管道初级测试 写两个小程序 xff0c 一个负责向管道发数据 xff0c 一个从管道接收数据 xff1b pipe cpp include lt iostream gt using namespace std int main cout
  • IPC:system V消息队列

    ftok函数 ftok convert a pathname and a project identifier to a System V IPC key SYNOPSIS include lt sys types h gt include