Skip to content
Advertisement

Tag: c++

Can a fork child determine whether it is a fork or a vfork?

Within the child process, is there any way that it determine whether it was launched as a fork with overlay memory, or a vfork with shared memory? Basically, our logging engine needs to be much more careful (and not log some classes of activity) in vfork. In fork it needs to cooperate with the parent process in ways that it

xcb_poll_for_event causes 100% usage of one cpu core

I’m learning c and messing around with xcb lib (instead of X11) on a raspberry pi4. The problem is that when implementing the events loop with xcb_poll_for_event instead of xcb_wait_for_event, one core of four is 100% full. What am I doing wrong? And is there any benefit of using wait_for_event (blocking way) instead of xcb_poll_for_event(non blocking)? The goal is to

Get files access permissions using stat() in C

I just started learning linux/C, i just want to show the names of all the files of the directories given in argument, and their access permissions by using stat() which causes some problems. It actually shows the correct name/mode of all the files included in the current directory, but for the other directories given in argument, it does give the

Send a kill signal to self

I have a C++ code that runs a linux command, I want to simulate segfault i.e. SIGSEGV while executing that linux command from by C++ code. So my code looks like this What should I put in “cmd” so that it can send SIGSEGV to the sub-process created by calling this function? Answer Sending kill signal to self can by

How do I print array of u16 in C?

I’d like to print both MSB and LSB of a u16 variable, here is my code: This code just print the LSB part in hexa format, but can you tell me how do I print the MSB part? Answer This code just print the LSB part Well of course, buf[0] = reg; only copies 8 bits. And what result you

Unexpected behaviour of SO_SNDTIMEO and SO_RCVTIMEO

I’m trying to set the timeout for the blocking TCP socket on Linux using setsockopt with SO_SNDTIMEO and SO_RCVTIMEO. But for some reason I get a lock while waiting on recv call. Consider the minimal example. I’ve shortened it a bit for readability, the full code is available in this gist. I create a server socket and set the timeouts

Advertisement