How does one check if a serial port is already open in Linux using Posix/C functions? I want to check the status of the serial port to check if the serial port is open or not. I would like to know what methods work for: Checking the file descriptor to see if the serial port is open and Checking the
Tag: c++
Segmentation Fault on pthread_create
I am having an issue with the following C code. The code itself is supposed to create 5 threads that simulate the Dining Philosophers problem in which threads are accessing shared data. The code follows: I am on a Linux virtual machine, using gedit. The program compiles fine, but upon attempting to run it, I am getting a “Segmentation Fault”
IPv6 multicast interface selection
The setsockopt way to select an interface for the outgoing traffic with IPv4 is IP_MULTICAST_IF, which accepts two arguments. From the ip(4) manual page: Set the local device for a multicast socket. The argument for setsockopt(2) is an ip_mreqn or (since Linux 3.5) ip_mreq structure similar to IP_ADD_MEMBERSHIP, or an in_addr structure. When trying to do the analogous operation with
fopen() returns inavlid argument when writing on SD card?
I’m trying to write a file on SD card if it’s inserted into the kit. Otherwise, the file should be written to the current directory of the project. I can write the file in the project’s directory without any problems. However, when I try to write it on the inserted SD card, it returns Invalide argument! I tried changing the
Are BIGNUM BN_ functions deprecated in openssl 1.1?
I was compiling some ‘C’ code that uses openssl under Fedora 27 (version 1.1.0g-1). I made some needed changes (from the 1.0.2 version of my code) and things now compile o.k. again. I then tried to compile with the option “OPENSSL_API_COMPAT=0x10100000L” which I understand causes the compiler to not include APIs deprecated in openssl version 1.1. Now, my code won’t
How can “plugins” loaded by libdl refer to symbols in the program which loaded them?
Imagine that you have an application with a plugin based architecture, where each plugin is a *.so file that is dynamically loaded with dlopen(). The main application can refer to symbols via dlsym(), and so it may call functions of the plugin. How can the plugin call functions of the main application? I know that the main application could provide
How to log to /var/log/mail.log using rsyslogd?
I am currently playing around with logging under Linux. I have made the following very simple test application (in plain C): This “application” compiles, and when I execute it, it generates an entry in /var/log/syslog, but no entry in /var/log/mail.log and no entry in /var/log/mail.err. Could somebody please explain why? I am using rsyslogd on the test machine; this is
Minimize all application windows when a modal window gets minimized (on Linux)
I have an application with some windows, and one of them is modal. On Windows OS, when I minimize the modal window all other windows minimize as well. On Linux (I’m using Astra Linux) only the modal window minimizes and all other windows state doesn’t change, and they are not available for any action, like if they were disabled. What’s
Bash on Ubuntu on Windows: Signal handler does not work
I try to run a simple program (code below), that should receive and handle the SIGUSR1 signal. It works well on “real” Linux, but if I run it on WSL after sending SIGUSR1 it prints User defined signal 1 and terminates. AFAIK this means that SIGUSR1 wasn’t handled by program and default handler was called. How can I make signal
How to find which process owns the named posix semaphore lock? [closed]
Closed. This question needs debugging details. It is not currently accepting answers. Edit the question to include desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem. This will help others answer the question. Closed 4 years ago. Improve this question I used named semaphore to synchronize multiple processes in my system. One of