Skip to content

Tag: posix

What type of memory objects does `shm_open` use?

Usually, shared memory is implemented using portions of On-Disk files mapped to processes address spaces. Whenever a memory access occurs on the shared region, the filesystem is involved to write changes on the disk which is a great overhead. Typically, a call to fopen() returns a file descriptor which is pas…

How to ensure a posix c socket is still valid

I,m working on an embedded linux kernel 2.6 device and need to know if previously established socket is still valid or not,Also I can not do this with usual send function and check the returned value,because if I send to the invalid socket descriptor,my application will crash and linux will shut down my proce…

Why sem_t pointer have to start at multiple of 4 offset?

When you accessing block of memory (f.e. in real case using mmap) correct pointer for sem_t have to by multiple of 4. If it is not, then sem_init() still doesn’t return -1 (error value), but sem_t isn’t valid. Why it is working like this? Below code that is showing behaviour of semaphores. Answer …

Trimming string up to certain characters in Bash

I’m trying to make a bash script that will tell me the latest stable version of the Linux kernel. The problem is that, while I can remove everything after certain characters, I don’t seem to be able to delete everything prior to certain characters. Somehow the output “ignores” the wget…

Why makecontext’s func only accepts integer arguments

The man page for makecontext states that the arguments after argc should be integer(int) only: …the function func is called, and passed the series of integer (int) arguments that follow argc If we look at pthread_create or clone system call, they have one void* argument which is to passed to the func, a…