Once I call socket(); bind() (with a specific IP address, not INADDR_ANY); listen(), there seems to be no way of determining if the IP address is still a valid address of one of the system’s interfaces. What I looked into using: Checking error with getsockopt(SO_ERROR); Using epoll()-ing on some EPOLLERR, EPOLL{,RD}HUP events; Hoping that accept() would return an error if
Tag: c++
Copy a file from one directory to another in C++
I am writing a C++ program to copy one file from one directory to another. I don’t want to use C++ 17 features. I have already implemented this in the following code. I am on Linux and I want to use the OS cp command to do this. I have written this code. The error is: cp: source: No such
Windows User Impersonation in .NET Core on Linux?
I’m writing a .NET Core application in C# that will run on a Linux server, but I need to impersonate a Windows user in order to access some remote resources on a Windows Server. I have credentials to authenticate there, but all the implementations I see rely on the “Advanced Windows 32 Base API” (advapi32.dll), which is a shared Windows
How to launch the same linux process with different arguments in multiple threads with Poco process
When trying to launch the same C++ Linux program, with different arguments and with Poco::process, I get exit 72 code from my second DummyProcess. This code snippet below is executed in a thread function, which launches every other time, with different task and duration arguments. When task-1 is running and task-2 wants to launch, its PID gets assigned (different then
Opengl using freeglut on linux shows only a transparent window
I am trying to use freeglut3 on linux mint 20 to do some basic openGL ( my teacher forced me to use glut/freeglut with c++ ). I am just trying to make a black window to show on screen but only a transparent window shows up and it doesn’t close until it shows Segmentation fault (core dumped) here is my
How to use SIGEV_THREAD, sigevent for linux-timer(s) expiration handling in C?
Problem: I have timer(s) running, upon expiration of timer(s) certain function needs to be invoked. Output: There is a segfault inside Hndlr() function As per man page of sigevent, it says, SIGEV_THREAD – Notify the process by invoking sigev_notify_function “as if” it were the start function of a new thread. (Among the implementā tation possibilities here are that each timer
How can I ask GCC to use a different standard library?
I have a debug version of libstdc++ 6 in /usr/lib/debug/usr/lib/x86_64-linux-gnu/. I would like to tell gcc/g++ to use this library instead of the standard library version without debug symbols. I tried using -nostdlib and passing the library path explicitly with -L, but get linking errors such as It seems that the library version (according to the file name) is the
Share Memory in Linux using C
Is it safe to use shm_unlink even there are other process currently open the shared memory? For exmaple: Process B shm_open and then Process A shm_unlink. Is it ok for Process B? Answer Yes, it is safe to call shm_unlink if another process has it opened. Per the man page for shm_unlink: The operation of shm_unlink() is analogous to unlink(2):
Accessing physical address space using mmap in Linux: passing the correct arguments to mmap
I need to access and write to some physical addresses in my RAM. I was looking at this answer and the definition of mmap. If addr is NULL, then the kernel chooses the (page-aligned) address at which to create the mapping; this is the most portable method of creating a new mapping. If addr is not NULL, then the kernel
The std::filesystem current_path returns the root one
I just wanna to print the current path and its content, via std::filesystem::path::current_path (the compiler is emcc this one). Some code below: And for windows it works fine, the output looks like: However, whether for Linux subsystem or for docker container with Ubuntu image it just prints the root directory: May be I something missed apropos the Linux’s std::filesystem? Answer