Questions tagged [unistd.h]

unistd.h is a C/C++ header files contains needed to provide access to the POSIX operating systems

Links:

https://en.wikipedia.org/wiki/Unistd.h

https://pubs.opengroup.org/onlinepubs/009695399/basedefs/unistd.h.html

175 questions
0
votes
2 answers

Compile file from inside the application with execl

I'm trying to compile a file from my application,with this action: - (IBAction)build:(id)sender { pid_t pid=fork(); int status; if(!pid) { execl("/Developer/usr/bin/gcc","-o main ~/main.c"); exit(0); } …
Ramy Al Zuhouri
  • 21,580
  • 26
  • 105
  • 187
0
votes
1 answer

Porting klib's knetfile.c|h to windows, when I sub in the "windows unistd.h", I get error C2036: 'void *' : unknown size

First, by "windows unistd.h", I mean the example located here: "is there a replacement for unistd.h for windows? I am attempting to massage knetfile.c so that it can be compiled for windows64. My first step was to remove the unistd.h include,…
rlong
  • 187
  • 3
  • 10
0
votes
1 answer

Using grep in execl with file descriptor

I'm trying to do the following: execl("/bin/grep","grep","print",fd,NULL); where fd is a file descriptor. So basically this should grep for "print" in the file pointed to by fd. It doesn't seem to work although I get no compile errors/warnings. It…
ffledgling
  • 11,502
  • 8
  • 47
  • 69
-1
votes
1 answer

How to use write() and read() in unistd.h

I'm trying to use the functions read() and write() from unistd.h, but whenever I try input anything, it does not work. And I am only alowed to use functions from fcntl.h and unistd.h, not those from stdio.h. Here is my code: #include
Gabi
  • 9
  • 4
-1
votes
1 answer

System call read result display random characters after the result

I've recieved this assignment where I have to read from a file.txt(max size 4096B) four times, basically splitting it in 4 strings of equal size. I have to fill this structure(just consider field 'msg', i think the problem is there): struct message…
iLux24
  • 3
  • 1
-1
votes
1 answer

Whats wrong with rand function in C

what can be the reason of bad result in generating random number in C? See my code below. The result should be number between 0 - 1. But when i print random number the result is: Doba prichodu: 690522220 n-times. And yes i am using…
-1
votes
3 answers

What does fork() == 0 returns?

I have 2 programs and I'm very confused on the return of fork() in child process The first program would call fork() and assign it to p. When p == 0, it implies child process. // The first program p = fork(); if (p == 0) { // child…
Peter
  • 437
  • 1
  • 4
  • 20
-1
votes
1 answer

How can I visualise how many processes this code creates?

How many processes does this piece of code create? for(int i = 0 ; i < 5 ; i++){ if(fork() == fork()) break; }
tugayicoru
  • 39
  • 3
-1
votes
2 answers

atof coredump with getopt

I'm writing a C++ application which converts fahrenheit to celsius and kelvin, and kelvin to celsius and fahrenheit, etc. Since it's stupid to write an interative application here, I decided to familiarize myself with the getopt function in…
-1
votes
2 answers

Why does my code exit with exit code: 0 even though the loop condition is still valid?

I am trying to use fork with execvp to run two shell commands concurrently. I have two problems which are when I input mkdir folder1&mkdir folder2, it creates a folder named folder1 and another folder named folder2? (the question mark is included in…
Ambitions
  • 2,369
  • 3
  • 13
  • 24
-1
votes
2 answers

Libraries "X11/Xlib.h", "X11/Xutil.h", "unistd.h" for Windows

I've done a C program that takes the RGB values (0-255) of a pixel of the screen knowing its position (x,y). It works in Linux, but when I try to compile it in Visual Studio (Windows), crashes because libraries X11/Xlib.h, X11/Xutil.h, unistd.h…
Sergio
  • 844
  • 2
  • 9
  • 26
-1
votes
1 answer

unistd : no such file or directory

I have the following test.cpp file : #include int main() { return 0; } I just want to compile this but I still have the following : $ g++ test.cpp test.cpp:1:18: fatal error: unistd: No such file or directory #include
vmonteco
  • 14,136
  • 15
  • 55
  • 86
-1
votes
1 answer

Why isn't execlp() printing output to the terminal?

I am trying to link the output of a child process into the input of a parent process; the parent process is to execute a system call or command using the child's output. I have looked to the following threads for answer; however, I didn't quite get…
Tyler K
  • 110
  • 1
  • 11
-1
votes
2 answers

How to know what number a system call has in linux

So I need to know what number a certain system call has , it says that I can check which number a systemcall has in unistd.h file but how/where can I find that file?
Antivirus
  • 1
  • 3
-1
votes
1 answer

How can i keep reading from a file using read from unistd.h

I'm using Qt for a project. I'll constanly read from a file with read from unistd.h, but how can i do that? I have tried to use an infinite while loop but my application crash when i do that. PS i'm beginner when it comes to Qt and fileoperation…
Loc Dai Le
  • 1,661
  • 4
  • 35
  • 70
1 2 3
11
12