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
1 answer

Get the original location where the program is called

Is there any way to know the directory where the program is originally spawned in C? I want my program to know where it is located in the computer. I already tried using _getcwd() in direct.h. I also tried getcwd() using unistd.h. But here's the…
Bryan James
  • 65
  • 1
  • 11
0
votes
1 answer

getpid on linux while using -std=c++11 as compiler flag

I would like to use getpid function from headers sys/types.h, unistd.h (C style) when I am using -std=c++11 flag but after that I have : "function getpid could not be resolved". Is there is some kind of workaround or equivalent function? @Edit: I…
user3626411
  • 188
  • 2
  • 3
  • 15
0
votes
2 answers

Argument Line Option Parsing for C

I've looked at many of the questions asked here before, and I've decided to go with unistd.h for getopt. However I have a need that a certain option depends on a previous option, as in exe -a a_opt -b b_bopt where the -b will do b_opt/a_opt So it…
Blue Granny
  • 772
  • 1
  • 8
  • 24
0
votes
1 answer

C++ SIGINT and SIGSTP over ctrl+c and ctrl+z

I am writing on a shell and want to implement the signals SIGSTP and SIGINT. When the user starts a new process and presses CTRL+C it should send a SIGINT to the process and when CTRL+Z is pressed the process should get the SIGSTP signal. Here is…
user3653164
  • 979
  • 1
  • 8
  • 24
0
votes
1 answer

How to replace or resolve __TVOS_PROHIBITED dependencies in unistd.h

I'm trying to compile a dependent libraries from the source code and I've got this error: /Applications/Xcode.app/Contents/Developer/Platforms/AppleTVOS.platform/Developer/SDKs/AppleTVOS9.0.sdk/usr/include/unistd.h:446:8: note: 'fork' has been…
PerfectGamesOnline.com
  • 1,774
  • 1
  • 18
  • 31
0
votes
4 answers

Can a CPU keep a process in pending state for 10 seconds, while a child process is executing?

This question was a part of my Mid-Sememter Exams, and its answer as given by the prof is quite absurd. I just want to know what is correct answer. CODE: #include // Other Libraries void ChildProc() { sleep(10); …
Pinkesh Badjatiya
  • 346
  • 1
  • 5
  • 15
0
votes
2 answers

Where are the files necessary to modify when adding a system call to linux-2.6.31

when i search for adding a system call, i get many articles but they seem to be for old versions, it also seems like a trivial process. But the problem is, the directories that articles suggest does not hold for the version 2.6.31. does anyone know…
besamelsosu
  • 461
  • 3
  • 11
0
votes
2 answers

How can I output a syscall’s name according to the number in the file unistd_64.h or unistd_32.h?

for example there are some macros in the unistd_64.h ... #define __NR_semget 64 #define __NR_semop 65 #define __NR_semctl 66 #define __NR_shmdt 67 #define __NR_msgget 68 #define __NR_msgsnd 69 ... when I input a number 64 , it will…
Jialin
  • 2,415
  • 2
  • 14
  • 10
0
votes
6 answers

Unable to pass char pointer to gethostname (Linux)

The following C program attempts to fetch and print the host name of the current RHEL host. It throws a segmentation fault on this machine. As per the definition of gethostname I should be able to pass a char pointer, shouldn't I? When I use a char…
pmn
  • 187
  • 1
  • 1
  • 10
0
votes
2 answers

implicit declaration of function swab

EDIT: the warning in the first paragraph was due to me reading the old log from the compiler (before including unistd.h, sorry for the missconfusion, the second problem still resides) I have a code that makes use of the c function unlink (declared…
cpaitor
  • 423
  • 1
  • 3
  • 16
0
votes
1 answer

Directory prwoling recursive functions isn't invoked

One of the issues I've encountered whilst making a recursive directory lister is that a call after a directory check isn't invoked in the recursive function's stack. void direct_crawl(int indent, char *cwd, STAT nstat) { int i, i_in, count; …
x86ris
  • 61
  • 1
  • 5
0
votes
3 answers

C copy file contents from EOF to SOF

My program is working almost as it should. The intended purpose is to read the file from the end and copy the contents to destination file. However what confuses me is the lseek() method more so how I should be setting the offset. My src contents at…
Sterling Duchess
  • 1,970
  • 16
  • 51
  • 91
0
votes
0 answers

Different result from read() function when writing to int or char

I am using read() from unistd.h on a file descriptor. I need to read the first 4 bytes to an int variable and the rest to a unsigned char array. So far, this does not work for getting the first 4 bytes: unsigned int myInt = 0; status = read (fd,…
tzippy
  • 6,458
  • 30
  • 82
  • 151
0
votes
2 answers

sys/stat.h returning wrong size

I am using unistd.h sys/stat.h and what is interesting is that st_size is bigger than the value returned after read()? st.st_size returns 644 - read() returns 606, Any thoughts?
Alex
  • 389
  • 1
  • 2
  • 14
0
votes
1 answer

Sleep function call leads to which scheduler state?

I have a question with regard to the sleep function declared in unistd.h Assume we use a CFS scheduler. We have a process that is ready to run(lets call this "READY" state),it gets picked to run,and now is running(so called "RUNNING" state). During…
hit.at.ro
  • 306
  • 3
  • 11