Glusterfs的编译选项 #pragma GCC poison system popen

在研究Glusterfs3.3.1时遇到编译错误,由于#pragma GCC poison system popen的设置,系统调用system被禁用。Glusterfs通过提供runcmd接口作为替代,避免了system调用可能带来的问题。在libglusterfs/src/run.h中可以找到runcmd等灵活的接口实现。
摘要由CSDN通过智能技术生成

       最近一直在研究Glusterfs3.3.1,当因需在代码中加入system(cmd)调用时,编译器提示error:attempt to use poisoned ”system",即试图使用有毒的system调用,首先我检查了一遍代码,其实就是一个system调用。排除了代码编写错误。然后我突然想起了system调用需要慎用的,调用system的进程在调用system未返回时可能会阻塞而且会忽略某几种信号。我接下来在网上查了查资料,确实system调用时可能会有诸多问题。 


        我在Glusterfs的源码文件./libglusterfs/src/compat.h也找到了这句话:#pragma GCC poison system popen,所以,当我再代码中加入system,popen等调用时,编译器就会报错,禁止编译。


        问题又来了.我是自己编码实现类system的功能还是Glusterfs另有解决的办法的?显然,Glusterfs的研发团队足够的聪明,我们想的他们都替我们想好了,哈哈。在libglusterfs/src/下有run.h,实现了类system调用的接口runcmd等,且 使用非常灵活。run.h接口声明如下:

/*
   Copyright (c) 2008-2012 Red Hat, Inc. <http://www.redhat.com>
   This file is part of GlusterFS.
   This file is licensed to you under your choice of the GNU Lesser
   General Public License, version 3 or any later version (LGPLv3 or
   later), or the GNU General Public License, version 2 (GPLv2), in all
   cases as published by the Free Software Foundation.
评论 4
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值