简体   繁体   English

unistd.h不可用,如何使用fork()

[英]unistd.h is not available, How to use fork()

I want to exercise some UNIX commands using C language. 我想使用C语言练习一些UNIX命令。 When I include <unistd.h> header file and when I use fork() method it gives me a compile time error: "can not include unistd.h" . 当我包含<unistd.h>头文件时,以及当我使用fork()方法时,它给了我一个编译时错误: "can not include unistd.h" I check on he Internet and the fork() method is available in <unistd.h> header file only. 我检查了他的Internet,并且fork()方法仅在<unistd.h>头文件中可用。 Please help me on this. 请帮我。

  • Is now <unistd.h> is replaced with any other header file? 现在<unistd.h>是否已替换为任何其他头文件?
  • Even if I use "process.h" , that does not have a definition for fork() . 即使我使用"process.h" ,也没有为fork()定义。
  • How I can use fork() method? 如何使用fork()方法?

I have DOSBox v0.74 on my system (Windows 7, 64-bit). 我的系统上有DOSBox v0.74(Windows 7,64位)。

The DOSBox web site says it is an emulation of DOS for Unix machines, not an emulator of Unix for Windows (DOS) machines. DOSBox网站说,它是针对Unix计算机的DOS仿真,而不是针对Windows(DOS)计算机的Unix仿真器。 You need Cygwin or MinGW or something similar if you want to emulate Unix on Windows. 如果要在Windows上仿真Unix,则需要CygwinMinGW或类似的东西。

没有简单的方法可以在win32或dos上模拟fork()。

You always can declare anything yourself: pid_t fork(void); 您总是可以自己声明任何内容:pid_t fork(void); However, if your system don't have unistd.h, it isn't POSIX compliant (or you haven't installed headers at all). 但是,如果您的系统没有unistd.h,则说明它不符合POSIX(或者根本没有安装标头)。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM