I am using execv in C, but it demands to get the path of the command to get it executed, For example: To execute ls I must have char* command = “/bin/ls”; To execute gedit I must have char* command = “/usr/bin/gedit”; My question is how to get the string “/bin” or “/usr/bin” in C ? Answer You can get
Tag: c++
Function of shared library is loaded at different physical addresses for different processes
I get physical addresses of function “printf” in libc.so in two programs, and two physical addresses are different. And I read two different physical address, the content are almost the same. This means function “printf” has two copies in memory? Details: My os is 32-bit linux. Physical address is calculated by read “/proc/self/pagemap”. Physical address reading is implemented with fmem
add another timer on already running loop
Given the following program – The second timer handle is never run on the loop, since the loop is already running, and “Timer2 called” is never printed. So I tried stopping the loop temporarily after running it and then adding the second timer – But this again didn’t work, probably because the later lines won’t be executed after 1st loop
Reading in kernel second time overrides first instance
I have written a read function to read a file into buffer in Kernel space. Now, this function works really well and I am able to read contents of filename into buf by calling this function from my system call Then, I am calling this function again to read contents of secondfile into secondbuffer. The problem is that after calling
ARM linux userspace gpio operations using mmap /dev/mem approach (able to write to GPIO registers, but fail to read from them)
Kernel version 3.12.30-AM335x-PD15.1.1 by PHYTEC. If I use the /sys/class/gpio way, I can see that the button input pin (gpio103 of AM3359) value changes from 0 to 1. Following the this exercise http://elinux.org/EBC_Exercise_11b_gpio_via_mmap and executing the below command for reading gpio pins usig /dev/mem approach: (base of gpio bank 3 which is 0x481ae000 + 0x13c dataout offset) I get the
access order of std::atomic bool variable
I’ve a function that accesses(reads and writes to) a std::atomic<bool> variable. I’m trying to understand the order of execution of instructions so as to decide whether atomic will suffice or will I’ve to use mutexes here. The function is given below – I’ve read this page on cppreference which mentions – Each instantiation and full specialization of the std::atomic template
ld undefined reference, despite library found and symbols exported
Been fighting with this on and off for 48 hours now; I’m still getting undefined reference errors when attempting to link a dynamic library with its dependency – despite all exports existing, and the library being found successfully. Scenario: libmemory (C++) – exports functions with extern “C” libstring (C) – exports functions, imports from libmemory libmemory builds successfully: libstring compiles
When is scons “Depends” useful when compiling c/cpp files?
Any c/cpp files can call functions defined in other module, only linking phase resolve them. These c/cpp files don’t depend on each other for compiling sequence. So my question is, is there any case that one c/cpp file should depend on another one, so that we need to specify in SConstruct like: Thanks! Answer It can be useful to force
How do I find waiting readers/writers for Linux System V Msg Queues?
I’m tasked with porting some C/C++ code that uses System V queues from HP-UX to Red Hat Linux (SVr4). Most of the calls have translated over fine, but I’m having difficulty with one specific issue as it relates to discovering waiting readers and writers on a given queue. On HP, one can use msgctl(IPC_STAT) to obtain a msqid_ds struct with
Why signal handler for SIGSEGV doesn’t catch my C++ throw exception?
I was trying to see if SIGSEGV signal hander could help to deal with unhandled exception of C++, I experiment it: $ g++ -g h.cpp -rdynamic && ./a.out terminate called after throwing an instance of ‘int’ Aborted (Core dump) Well, the program doesn’t print crash call stack back trace as I expected. My question is: As long as it terminates,