- c - 在位数组中找到第一个零
- linux - Unix 显示有关匹配两种模式之一的文件的信息
- 正则表达式替换多个文件
- linux - 隐藏来自 xtrace 的命令
我从文档中复制了这个程序:https://docs.oracle.com/cd/E19455-01/806-4750/signals-7/index.html
#include <stdio.h>
#include <signal.h>
#include <sys/wait.h>
#include <sys/resource.h>
void proc_exit()
{
int wstat;
union wait wstat;
pid_t pid;
while (TRUE) {
pid = wait3 (&wstat, WNOHANG, (struct rusage *)NULL );
if (pid == 0)
return;
else if (pid == -1)
return;
else
printf ("Return code: %d\n", wstat.w_retcode);
}
}
main ()
{
signal (SIGCHLD, proc_exit);
switch (fork()) {
case -1:
perror ("main: fork");
exit (0);
case 0:
printf ("I'm alive (temporarily)\n");
exit (rand());
default:
pause();
}
}
当我运行 gcc main.c
时,我得到这个错误:
main.c: In function ‘proc_exit’:
main.c:9:13: error: conflicting types for ‘wstat’
union wait wstat;
^~~~~
main.c:8:6: note: previous declaration of ‘wstat’ was here
int wstat;
^~~~~
main.c:9:13: error: storage size of ‘wstat’ isn’t known
union wait wstat;
^~~~~
main.c:12:9: error: ‘TRUE’ undeclared (first use in this function)
while (TRUE) {
据我了解,wstat
被定义了两次。这是否意味着文档不正确?以及如何解决?
最佳答案
是的,那个密码刚刚坏了。我不知道 union wait wstat;
的意图是什么。也许是文档作者的一些复制粘贴错误。谁知道。总的来说,代码写得很糟糕,IMO。
无论如何,下面是代码实际要执行的操作:
int wstat;
pid_t pid;
while (1) {
pid = wait3(&wstat, WNOHANG, NULL);
if (pid == 0 || pid == -1)
return;
printf("Return code: %d\n", wstat);
}
关于c - 错误 : conflicting types for ‘wstat’ in gcc,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56628418/
Postgres 10 和 11 的插入规范说: ON CONFLICT [ conflict_target ] conflict_action 我有一张 table : create table c
我的理解是conflict serializable 隐含serializable。我不确定这如何让他们与众不同。可序列化是否意味着冲突可序列化? 最佳答案 冲突可序列化是可序列化的一个子集,因此仅仅
在数据库理论中,“冲突可序列化”和“冲突等价”有什么区别? 我的教科书有一节是关于冲突可序列化的,但掩盖了冲突等价性。这些可能都是我熟悉的概念,但我不熟悉术语,所以我正在寻找解释。 最佳答案 DBMS
我有一个项目一直在 Xcode 4.4.1 中进行,我想回到以前的分支。(注意分支并不复杂,而是代表线性发展) 当我选择上一个分支时有一个警告 UserInterfaceState.xcusersta
我得到了一个 environment.ubuntu.yml文件,以便能够创建 conda 环境。但是,运行 conda create env --file environment.ubuntu.yml
我浏览了互联网,找不到我的问题的清晰简洁的答案。我想知道如果我将相同强度的信号驱动到同一根电线上会发生什么,其中一个是逻辑 1,另一个是逻辑 0?如果我想要一个“获胜”的信号,因为没有更好的词,我该怎
我在2个网站上有2个不同的图片: http://www.siteA.com/avatar.png http://www.siteB.com/avatar.png 如果我创建具有2个起源的Amazon
我正在 Labview 中开发一个数据采集程序,该程序使用多个转换阶段、相机、高速数字化仪和其他仪器。我正在一台计算机上开发该应用程序,并将其部署到另一台计算机上。开发计算机有labview 2013
能否请您帮助我理解为什么乐观并发更新会有这样的结果。 比如说,我有以下文件: { "phrase": "some phrase", "id": "5d1341797e2ed599", "_
我想安装这两个包: “anahkiasen/前任”:“开发大师” "vespakoen/menu": "dev-master" 但是 composer 说它们每个都依赖于这个包的不同版本: "anah
我在运行 powershell 时遇到以下错误 $thumbprint=$(az webapp config ssl upload --certificate-file $Path --certifi
我不太确定这是否是我使用的 SQLite 版本的问题。但实际上我并没有直接使用 native SQLite (dll),我使用的是 System.Data.SQLite 版本 1.0.108.0 看起
我有一个具有 iBeacon 服务和标准 BLE 服务的芯片。 我想使用 iBeacon 服务在进入 BLE 信号范围时触发我正在开发的应用。 激活后,我希望应用程序使用 CoreBluetooth
建表语句: ? 1
我使用此链接中的示例创建了测试 Telegram 机器人控制台应用程序 https://github.com/TelegramBots/Telegram.Bot.Examples 这是我的主要 pub
我有这个 hpp 文件: struct rte_spinlock_t; class A { public: void init(); private:
我已经从 GitHub 中提取了文件。现在我需要创建一个合并冲突。 如何在 GitHub 上故意创建合并冲突? 最佳答案 在两个分支中编辑同一行,并尝试合并 Merge conflicts in gi
我是这个 repo 的管理员。在这个 PR 中,我删除了多个文件并将这些更改从本地合并到源/开发。将 origin/develop 合并到 origin/master 时,我遇到了我删除的四个文件之一
我使用 Azure 表存储从 MVC 应用程序记录访问者信息,但有时会引发以下异常: [WebException: The remote server returned an error: (409)
我有一张 table : create table c ( e text not null, m text not null, p numeric not null,
我是一名优秀的程序员,十分优秀!