Trying to create socket application using c (Linux) to constantly fetch data from a server For this I have created a loop and inside it the routine connects , send a command, receive some data and close the socket. It works fine for the first interaction but looks like the recv function failing to update the buffer variable from second
Tag: c++
Signal Handling C programming on ubuntu
While I sending kill -9 command to a program on ubuntu , I want to close other running processes before the program closes.I am trying this with c programming . Could it be something like this? How can I say program if you get KILL command you should do something? Answer Per the POSIX standard <signal.h> documentation: … The following
Know who is the inheritor while debugging core dumps with GDB
My process has crashed, and I have a core dump. I see that the process crashed while running a code similar to that : I have a full call stack in the core dump, but I don’t know who is the inheritor that runs the “func”. Is there a way to figure it out (maybe by some pointer calculation tricks
C – get list of opened handlers – duplicate entries
I have this code to retrieve list of opened handlers (mostly FILE) However, when i call single fopen and run this, it prints the same file multiple times (from n to FD_SETSIZE, where n is some offset id… first 0 .. n are some system handlers like dev/nul etc.). Answer Your error check after fcntl(fd, F_GETFD, 0) is a bit
C Program that makes a copy of a file using standard I/O and system calls
I am trying to write a C program which uses standard I/O and System calls to perform copying of contents of one file to another file. So far, I have done this : When I run the program like this : Assuming that one.txt is well defined, what I want is to create a new file called two.txt and copy
Can I use 1G superpages to back shared mmaps?
So far when I’ve tried using a file in /mnt/hugepages1G/ as the backing I get segfaults. It works fine if I use 2M superpages in /mnt/hugepages/ I think I read somewhere that I now can’t find that Linux only supports 2M pages for Shared memory? But I can’t swear to it. Can’t find it in documentation. https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/Documentation/vm/hugetlbpage.txt?id=HEAD $ hugeadm –pool-list
libopencv_core.so.2.4: error adding symbols: DSO missing from command line
I have installed OpenCV 3.3.0 to Ubuntu 16.04. Just want to compile this code. g++ -o main gpu_thresh.cpp ‘pkg-config opencv –cflags –libs’ -lopencv_gpu -lopencv_core g++ -L/usr/local/lib -o main gpu_thresh.cpp ‘pkg-config opencv –cflags –libs’ -lopencv_gpu -lopencv_core I tried to compile it with these ways but still giving same warning and error. /usr/bin/ld: warning: libopencv_core.so.2.4, needed by /usr/lib/gcc/x86_64-linux-gnu/5/../../../x86_64-linux-gnu/libopencv_gpu.so, may conflict with libopencv_core.so.3.3
C code about pointers
I’ve got this simple code that plays with pointers taken from Jon Eriksen’s book that I’m trying to compile but gcc gives me warnings in compilation and segmentation fault (core dumped) when I run it. Output: Answer This program is wrong, and the advice given in the book is obviously wrong, too. A pointer can be converted to an integer
Reading Long Values From Sysfs Path With Escape Characters
I am using C file IO to read value from a sysfs interface in linux. Path and sample value of the register is as follows: Code: Added after intel-rapl to take into account unknown escape sequence The code compiles without any error, but in the output file I am getting value as 0. Is this due to how I
Why can I not read a UTF-16 file longer than 4094 characters?
Some information: I’ve only tried this on Linux I’ve tried both with GCC (7.2.0) and Clang (3.8.1) It requires C++11 or higher to my understanding What happens when I run it I get the expected string “abcd” repeated until it hits the position of 4094 characters. After that all it outputs is this sign “?” until the end of the