Unix & Linux Stack Exchange
Q&A for users of Linux, FreeBSD and other Unix-like operating systems
Latest Questions
0
votes
1
answers
1891
views
Including cURL in makefile
I'm using curl in my code and running through Makefile. but while running with "make" command its giving error like "curl/curl.h: No such file or directory". Here below is my makefile content. ` CXX = /home/directory/Documents/xyz/l4t-gcc/bin/aarch64-buildroot-linux-gnu-cc path = /home/directory/Doc...
I'm using curl in my code and running through Makefile. but while running with "make" command its giving error like "curl/curl.h: No such file or directory". Here below is my makefile content.
`
CXX = /home/directory/Documents/xyz/l4t-gcc/bin/aarch64-buildroot-linux-gnu-cc
path = /home/directory/Documents/xyz/l4t-gcc/bin/
CFLAGS = -Wall
#INCLUDE = -I/usr/local/include -I/usr/include -Iinclude
#LDFLAGS = -L/usr/local/lib -I/usr/lib
LDLIBS = -lcurl
SOURCES = src/sms_wrapper.c src/twilio.c
OUT = bin/sms_wrapper
all: build
build: $(SOURCES)
$(CXX) -o $(OUT) $(CFLAGS) $(SOURCES) $(LDLIBS)
clean:
rm -rf bin/sms_wrapper
`
I installed curl and added all things in Makefile which is needed for curl library. Does anyone have any suggestions or idea for resolving this thing !
nima
(1 rep)
Feb 13, 2023, 10:21 AM
• Last activity: Jul 29, 2025, 02:02 PM
0
votes
1
answers
83
views
In one process, any way to know whether there exists any other same program is running?
So I am designing a feature to redirect log file if there are multiple processes of this very program are running. I guess this requires me to somehow get to know whether there exists yet unfinished same program(executable?). I wonder is this achievable within user mode? How?
So I am designing a feature to redirect log file if there are multiple processes of this very program are running.
I guess this requires me to somehow get to know whether there exists yet unfinished same program(executable?). I wonder is this achievable within user mode? How?
PkDrew
(111 rep)
Jul 29, 2025, 01:35 AM
• Last activity: Jul 29, 2025, 09:50 AM
1
votes
1
answers
103
views
If fprinting to stderr fails, which error code should a C program return?
Assume the following C snippet showing a piece of error handling: ```C #include #include … int main(int argc, char argv*[]) { int retval=0; … if(3!=argc) { /* wrong number of arguments */ retval |= EX_USAGE; const int fprintf_retval = fprintf(stderr, "Bad syntax.\n"); if (0>=fprintf_retval) retval |...
Assume the following C snippet showing a piece of error handling:
#include
#include
…
int main(int argc, char argv*[]) {
int retval=0;
…
if(3!=argc) { /* wrong number of arguments */
retval |= EX_USAGE;
const int fprintf_retval = fprintf(stderr, "Bad syntax.\n");
if (0>=fprintf_retval) retval |= … Hmm … ;
}
…
return retval;
}
Which error constant from sysexits.h should be placed instead of “… Hmm …”? We can say EX_OSERR (a failure to print an error message shows that something is off, though not necessarily deep in the operating system), or EX_IOERR (it's an output error, though not necessarily into a file), or EX_SOFTWARE (fairly general, but the reason for a failure to print an error typically lies outside the C program, and the error might relate to the operating system). Based only on the comments in sysexits.h, neither of the three constants fits perfectly. So what's the convention?
EDIT: In the scope of this question, we assume that the programmer does want to discern between certain kinds of errors via the exit code, and that more than one error can occur.
user743115
(1 rep)
Jul 24, 2025, 12:48 AM
• Last activity: Jul 24, 2025, 09:15 AM
26
votes
3
answers
1826
views
Why does gmtime() give days 1-31, but months 0-11?
The 'gmtime()' standard library function returns a struct that has days numbered 1-31, but months numbered 0-11. Why is that? Presumably there is some historic reason?
The 'gmtime()' standard library function returns a struct that has days numbered 1-31, but months numbered 0-11.
Why is that? Presumably there is some historic reason?
ああああああああああああああああああああああああああああああ
(444 rep)
Jul 11, 2025, 10:04 AM
• Last activity: Jul 15, 2025, 01:57 PM
5
votes
5
answers
7405
views
/usr/bin/which returns cryptic error "which: no ls in ((null))"
I am writing a simple shell program. When I use /usr/bin/which with my shell in mac osx and ubuntu, it acts normally. When I use the exact same command on Red Hat Enterprise Linux Client release 6.3 (Santiago), I get this error: "which: no ANYCOMMANDHERE in ((null))". Is there any intuition for this...
I am writing a simple shell program. When I use /usr/bin/which with my shell in mac osx and ubuntu, it acts normally. When I use the exact same command on Red Hat Enterprise Linux Client release 6.3 (Santiago), I get this error: "which: no ANYCOMMANDHERE in ((null))".
Is there any intuition for this? I can't even find what the error means (Let me know if showing my source will help).
**EDIT: My path is (from inside the shell):**
$ echo $PATH
/usr/lib64/qt-3.3/bin:/usr/local/bin:/bin:/usr/bin
Thanks,
Jon
Jonathan Friedman
(51 rep)
Oct 8, 2012, 09:17 PM
• Last activity: Jul 9, 2025, 11:25 AM
7
votes
1
answers
473
views
Syscalls required by glibc calls
Are there any lists compiled that provide a list of linux system calls used per function in a standard glibc build? For example, `free()` requires `mmap`, `munmap`, `mprotect`, `prlimit64`, and `brk`. If necessary I can figure this out by grepping the source code or some strace wizardry, but I don't...
Are there any lists compiled that provide a list of linux system calls used per function in a standard glibc build?
For example,
free()
requires mmap
, munmap
, mprotect
, prlimit64
, and brk
.
If necessary I can figure this out by grepping the source code or some strace wizardry, but I don't want to reinvent the wheel. I've been searching the web for about a week with no avail, mostly just turning up info on system call wrappers.
I am aware that officially there is no such certainty, but I know from practical experience that this info changes for most functions very rarely.
I asked this on Stack Overflow, but this forum seems more appropriate, since I am looking for documentation (which may or may not exist).
Thanks
user30972097
(73 rep)
Jul 5, 2025, 11:20 PM
• Last activity: Jul 6, 2025, 01:56 PM
4
votes
1
answers
3206
views
ioctl: invalid argument for HDIO_GET_IDENTITY
I wrote a program to get the details of hard disk drive using `HDIO_ ioctl calls`. For writing program, I'm referring [`Documentation/ioctl/hdio.txt`][1] in kernel source(2.6.32). Here is my main part of code: fd = open("/dev/sda", O_RDONLY); // validated fd. retval = ioctl(fd, HDIO_GET_IDENTITY, &d...
I wrote a program to get the details of hard disk drive using
HDIO_ ioctl calls
.
For writing program, I'm referring Documentation/ioctl/hdio.txt
in kernel source(2.6.32).
Here is my main part of code:
fd = open("/dev/sda", O_RDONLY); // validated fd.
retval = ioctl(fd, HDIO_GET_IDENTITY, &driveid);
if(retval < 0) {
perror("ioctl(HDIO_GET_IDENTITY)");
exit(3);
}
When I run(as root) the above code, I got below error:
ioctl(HDIO_GET_IDENTITY): Invalid argument
What is the wrong in the program?
Why I'm getting error?
**Additional Info**: OS: CentOS-6.5
, kernel version: 2.6.32
, IA:x86_64
(running on VMware).
Result of hdparm -i /dev/sda
is
SG_IO: bad/missing sense data, sb[]: 70 00 05 00 00 00 00 0a 00 00 00 00 20 00 00 c0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
HDIO_GET_IDENTITY failed: Invalid argument
gangadhars
(727 rep)
Apr 18, 2014, 06:18 AM
• Last activity: Jun 19, 2025, 06:09 PM
2
votes
2
answers
104
views
Sudo doesnt work in my C wrapper
I’m trying to write a C wrapper to run a bash process. The goal of this wrapper is to apply a seccomp policy to restrict certain syscalls. Here is the code: ``` #define _GNU_SOURCE #include #include #include #include #include #include #include // Function to apply seccomp filter void apply_seccomp_f...
I’m trying to write a C wrapper to run a bash process. The goal of this wrapper is to apply a seccomp policy to restrict certain syscalls.
Here is the code:
#define _GNU_SOURCE
#include
#include
#include
#include
#include
#include
#include
// Function to apply seccomp filter
void apply_seccomp_filter() {
scmp_filter_ctx ctx;
// Initialize seccomp context with default allow policy
ctx = seccomp_init(SCMP_ACT_ALLOW);
if (ctx == NULL) {
perror("seccomp_init");
exit(EXIT_FAILURE);
}
// Block finit_module syscall
if (seccomp_rule_add(ctx, SCMP_ACT_ERRNO(EPERM), SCMP_SYS(finit_module), 0) < 0) {
perror("seccomp_rule_add: finit_module");
seccomp_release(ctx);
exit(EXIT_FAILURE);
}
// Load the filter
if (seccomp_load(ctx) < 0) {
perror("seccomp_load");
seccomp_release(ctx);
exit(EXIT_FAILURE);
}
seccomp_release(ctx);
}
int main() {
apply_seccomp_filter();
execl("/bin/bash", "bash", NULL);
perror("execl");
return EXIT_FAILURE;
}
The code works fine to block the syscall, but when I try to run sudo, I get this message:
sudo: The "no new privileges" flag is set, which prevents sudo from running as root.
sudo: If sudo is running in a container, you may need to adjust the container configuration to disable the flag.
Do you know how to disable this flag? All the answers I find online are related to containers like Docker, but that’s not my case.
Thanks in advance for your help!
Liric Ramer
(85 rep)
Jun 16, 2025, 03:07 PM
• Last activity: Jun 17, 2025, 10:08 AM
0
votes
0
answers
42
views
Panfrost kernel driver on FreeBSD for rk3566?
We are two FreeBSD lovers and a stubborn system administrators. We are trying to project a phone based on FreeBSD for several months. Emanuel Vadot and Jesper Schmitz Mouridsen have enabled the panfrost driver already,but on the rockpro RK3399,but for my phone I've chosen the smaller Radxa board. Th...
We are two FreeBSD lovers and a stubborn system administrators.
We are trying to project a phone based on FreeBSD for several months.
Emanuel Vadot and Jesper Schmitz Mouridsen have enabled the panfrost driver already,but on the rockpro RK3399,but for my phone I've chosen the smaller Radxa board. These are their github with their kernel patches code :
https://github.com/evadot/drm-subtree
https://github.com/jsm222/drm-subtree
We are trying to see if the panfrost driver worked on that board.
Unfortunately,it seems that some code is missing,such as the vop2.
Anyway,I want to show you the error that we get :
We would have some clarification about what's missing,what should be fixed in the code.
Eventually I could hire a FreeBSD kernel developer to produce the patch needed to enable it on the Radxa board.
It makes no sense to run FreeBSD on a phone without being able to use its GPU / MALI / acceleration.
We need a vop2 driver. Linux driver has 5000 lines of code and supports all of the vop2 variants
.compatible = "rockchip,rk3566-vop",
.compatible = "rockchip,rk3568-vop",
.compatible = "rockchip,rk3576-vop",
.compatible = "rockchip,rk3588-vop",
this 5k lines do not include support for the rk3588 newer hdmi variants but lets ignore that for now and assume that current hdmi code will work for rk356x ; also from what i've seen the current linux vop2 code is for a newer release of drm than what evadot's code uses so the api is slightly different.
Please enlighten us with some lucid considerations.
Someone wants help us ?
Thanks.

mister_smith
(1 rep)
Jun 16, 2025, 09:48 AM
• Last activity: Jun 16, 2025, 08:58 PM
0
votes
0
answers
44
views
Window move bound to display area
Trying to move a window by grip-able button. On 2 other window managers, and no manager it works fine. Windows move anywhere you want pass display edge bounds. On GNOME Shell and Mutter(Gala) the window is confined to the desktop view with no part of it allowed past display edges. On Compiz I use _N...
Trying to move a window by grip-able button. On 2 other window managers, and no manager it works fine. Windows move anywhere you want pass display edge bounds. On GNOME Shell and Mutter(Gala) the window is confined to the desktop view with no part of it allowed past display edges. On Compiz I use _NET_WM_MOVERESIZE, other 2 are grab_pointer. The mutter variants won't work using _NET_WM_MOVERESIZE which is fine, but I can't figure out what property to set on the window to allow normal configure messages to get past display limits. Hint as to which it is would be appreciated, kinda would like to support the variant.
Need a window_property_set or client message to root to be able to use configure_window.
Using code:
#if USE_XLIB
XMoveWindow(display, motion->event, values, values);
#else
xcb_configure_window(session->connection, motion->event,
XCB_CONFIG_WINDOW_X | XCB_CONFIG_WINDOW_Y, values);
#endif
This will only allow movement to the confines of 'maximize' window display. Moving left, negative x values get converted by GNOME to 0. Moving toward bottom, any value greater than window.y + window.height gets converted to display height - taskbar height - window height by GNOME. Verified by values received on configure notify.
Do I need to delete a _NET_WM_STRUT property on my window or root window to use? Looking at gdk3 code they use the Xlib variant of code.
**Solved**\
Problem is issue that GNOME only supports move of window correctly through their toolkit. It appears to lack proper support of both EWMH and ICCCM. Workaround is to use override-redirect, taking away its ability to mess with configure message.
user748603
(1 rep)
May 29, 2025, 09:40 PM
• Last activity: May 31, 2025, 10:13 PM
0
votes
2
answers
44
views
when opening a FIFO for reading+writing, and blocking - how to tell if other side opened for reading or writing?
If I open a fifo for reading+writing in blocking mode: fd = open("foo", "O_RDWR"); Then it blocks until someone on the other end opens it for either reading or writing. But how do I know which? if(???) { read(fd, .......); } else { write(fd, ......); } close(fd); (I need that close, because if I am...
If I open a fifo for reading+writing in blocking mode:
fd = open("foo", "O_RDWR");
Then it blocks until someone on the other end opens it for either reading or writing. But how do I know which?
if(???) {
read(fd, .......);
} else {
write(fd, ......);
}
close(fd);
(I need that close, because if I am writing I need to send an EOF to the other end. And any writer will send a single line through and close, so I also need to close if I read.)
What do I put instead of the ??? to figure out what the other end did?
Is non-blocking and
select()
my only option? Is there a way to inspect fd
and see if it's ready for reading or writing?
Ariel
(117 rep)
May 30, 2025, 06:30 PM
• Last activity: May 31, 2025, 06:15 AM
1
votes
1
answers
2177
views
libpcap missing
I’m trying to run a C program, but every time I try to run it I get this message: error while loading shared libraries: libpcap.so.0.8: cannot open shared object file: No such file or directory I've re-installed `libpcap`; I've installed `gcc` and `g++`; I’ve updated it and I’m lost. I’m not sure wh...
I’m trying to run a C program,
but every time I try to run it I get this message:
error while loading shared libraries: libpcap.so.0.8: cannot open shared object file: No such file or directory
I've re-installed
libpcap
; I've installed gcc
and g++
; I’ve updated it and I’m lost. I’m not sure what else I can do. Could anyone help out?
Adam
(11 rep)
Feb 28, 2015, 01:14 AM
• Last activity: May 27, 2025, 05:00 PM
0
votes
1
answers
31
views
Failed to register hook to tracepoint of signal_generate in Linux?
I am testing `FTRACE` in Linux VM (ubuntu 24.04) the kernel is `Linux VirtualBox 6.11.0-26-generic`. I wrote a kernel module to register a hook (probe) to kernel tracepoint of `signal_generate`, here is the code. ``` include #include #include static void trace_signal_generate_handler(void *ignore, i...
I am testing
FTRACE
in Linux VM (ubuntu 24.04) the kernel is Linux VirtualBox 6.11.0-26-generic
.
I wrote a kernel module to register a hook (probe) to kernel tracepoint of signal_generate
, here is the code.
include
#include
#include
static void trace_signal_generate_handler(void *ignore, int sig, struct kernel_siginfo *info,
struct task_struct *task, int type, int result)
{
printk("Signal %d generated for task %s (PID=%d), type=%d\n",
sig, task->comm, task->pid, type);
}
static int __init my_module_init(void) {
int ret;
ret = register_trace_signal_generate(trace_signal_generate_handler, NULL);
if (ret) {
pr_err("Failed to register tracepoint: %d\n", ret);
return ret;
}
return 0;
}
static void __exit my_module_exit(void) {
unregister_trace_signal_generate(trace_signal_generate_handler, NULL);
tracepoint_synchronize_unregister();
}
module_init(my_module_init);
module_exit(my_module_exit);
MODULE_LICENSE("GPL");
MODULE_AUTHOR("wangt13");
MODULE_DESCRIPTION("Signal Generate Tracepoint Hook Example");
When I compiled this module, I hit following error.
make: Entering directory '/usr/src/linux-headers-6.11.0-26-generic'
warning: the compiler differs from the one used to build the kernel
The kernel was built by: x86_64-linux-gnu-gcc-13 (Ubuntu 13.3.0-6ubuntu2~24.04) 13.3.0
You are using: gcc-13 (Ubuntu 13.2.0-23ubuntu4) 13.2.0
MODPOST /home/wangt/develop/kermod/Module.symvers
ERROR: modpost: "__tracepoint_signal_generate" [/home/wangt/develop/kermod/tracep_reg.ko] undefined!
make: *** [scripts/Makefile.modpost:145: /home/wangt/develop/kermod/Module.symvers] Error 1
make: *** [/usr/src/linux-headers-6.11.0-26-generic/Makefile:1879: modpost] Error 2
make: *** [Makefile:224: __sub-make] Error 2
I checked the /usr/src/linux-headers-6.11.0-26-generic/include/trace/events/signal.h
, and found it is defined there.
36 /**
37 * signal_generate - called when a signal is generated
38 * @sig: signal number
39 * @info: pointer to struct siginfo
40 * @task: pointer to struct task_struct
41 * @group: shared or private
42 * @result: TRACE_SIGNAL_*
43 *
44 * Current process sends a 'sig' signal to 'task' process with
45 * 'info' siginfo. If 'info' is SEND_SIG_NOINFO or SEND_SIG_PRIV,
46 * 'info' is not a pointer and you can't access its field. Instead,
47 * SEND_SIG_NOINFO means that si_code is SI_USER, and SEND_SIG_PRIV
48 * means that si_code is SI_KERNEL.
49 */
50 TRACE_EVENT(signal_generate,
51
52 TP_PROTO(int sig, struct kernel_siginfo *info, struct task_struct *task,
53 int group, int result),
54
55 TP_ARGS(sig, info, task, group, result),
56
57 TP_STRUCT__entry(
58 __field( int, sig )
59 __field( int, errno )
60 __field( int, code )
61 __array( char, comm, TASK_COMM_LEN )
62 __field( pid_t, pid )
63 __field( int, group )
64 __field( int, result )
65 ),
.......
I don't know why there was the error in module compiling.
I tried to hook another kernel tracepoint of kmalloc
as follows,
ret = register_trace_kmalloc(probe_kmalloc, NULL);
and it was compiled and loaded without error.
So how to fix the error of hooking probe to tracepoint of signal_generate
, and what is the right way to hook my probe to the tracepoint of signal_generate
from within kernel module?
wangt13
(631 rep)
May 24, 2025, 02:59 AM
• Last activity: May 24, 2025, 12:38 PM
0
votes
2
answers
62
views
Do race conditions occur during pathname resolution with constant string absolute path literals?
According to *The Open Group Base Specifications Issue 8*, on the rationale of the ```open()``` and ```openat()``` functions: > The purpose of the openat() function is to enable opening files in directories other than the current working directory without exposure to race conditions. Any part of the...
According to *The Open Group Base Specifications Issue 8*, on the rationale of the
()
and ()
functions:
> The purpose of the openat() function is to enable opening files in directories other than the current working directory without exposure to race conditions. Any part of the path of a file could be changed in parallel to a call to open(), resulting in unspecified behavior. By opening a file descriptor for the target directory and using the openat() function it can be guaranteed that the opened file is located relative to the desired directory.
This wording implies that **any use of ()
with a pathname that doesn't refer to a file in the current working directory is potentially subject to race conditions, even if the path is an absolute constant like /dev/null
.** While the string literal is immutable, the underlying path components (/
,
,
) can be altered by another process between resolution steps, leading to unintended behavior or security issues.
For example:
#define _POSIX_C_SOURCE 202405L
#include
#include
int main(void) {
int fd = open("/dev/null", O_RDONLY);
if (fd == -1) {
return 1;
}
...
(void) close(fd);
return 0;
}
So the only safe way to open it would be:
#define _POSIX_C_SOURCE 202405L
#include
#include
int main(void) {
int rootfd = open("/", O_SEARCH);
if (rootfd == -1) {
return 1;
}
int devfd = openat(rootfd, "dev", O_SEARCH | O_DIRECTORY);
if (devfd == -1) {
(void) close(rootfd);
return 1;
}
int nullfd = openat(devfd, "null", O_RDONLY);
if (nullfd == -1) {
(void) close(devfd);
(void) close(rootfd);
return 1;
}
...
(void) close(nullfd);
(void) close(devfd);
(void) close(rootfd);
return 0;
}
But the path used is a constant character literal that wasn't obtained from another function. I understand how a race condition could occur if there were a time window between retrieving the path and actually opening it, but not in this case. Doesn't my ()
example just replicate what the kernel already does internally during path resolution when using ()
with an absolute path?
**Note:** I used /dev/null
because it's guaranteed to exist, but my question applies to any path that refers to any file or directory in the filesystem.
Salubia
(1 rep)
May 19, 2025, 07:21 PM
• Last activity: May 20, 2025, 08:08 AM
1
votes
2
answers
3727
views
How to supply a command to 'stdin' of a running process from a second shell?
If you have a process that is waiting for user-input from the `stdin` scope, then how can you supply that user-input from a second terminal ? Specifically, if I run the c-program while(1){ fgets(string, len, stdin); string[strlen(string)-1] = 0; if(strcmp("Stop", string) == 0){ printf("Gotcha"); ret...
If you have a process that is waiting for user-input from the
stdin
scope, then how can you supply that user-input from a second terminal ?
Specifically, if I run the c-program
while(1){
fgets(string, len, stdin);
string[strlen(string)-1] = 0;
if(strcmp("Stop", string) == 0){
printf("Gotcha");
return 1;
}
}
then how can I supply the string "Stop" to stdin
of that process from another process, such that the first process will stop (and print "Gotcha") ?
I've tried to run the c-program in terminal 'pts/0' and open a new terminal ('pts/1') with commands:
$ echo "Stop" > /proc//fd/0
$ echo "Stop" > /dev/pts/0
where pid is the process id. The "Stop"-command is "repeated" in the first shell, but the process does not receive it.
drC1Ron
(181 rep)
Dec 21, 2018, 03:05 PM
• Last activity: May 19, 2025, 01:05 AM
0
votes
1
answers
2250
views
Buildroot compile error, librt.so: undefined reference to
I'm trying to compile a [Buildroot](https://bellard.org/tinyemu/buildroot-riscv-2018-10-20.tar.gz) image using a preconfigured builtin _defconfig file... More specific the riscv64_xwin_defconfig which is a simple setup for a riscv64 image with Xorg builtin. Since it's a rather old build i'm doing th...
I'm trying to compile a [Buildroot](https://bellard.org/tinyemu/buildroot-riscv-2018-10-20.tar.gz) image using a preconfigured builtin _defconfig file... More specific the riscv64_xwin_defconfig which is a simple setup for a riscv64 image with Xorg builtin.
Since it's a rather old build i'm doing this inside a Fedora 23 Docker container which has gcc version 5.3.1, i don't think this is a problem since i can successfully build the non-Xwin riscv64 defconfig just fine
The problem resides when the Makefile tries to build the specific package "eudev-3.2"
Here is the config.log:
configure:3158: $? = 1
configure:3178: checking whether the C compiler works
configure:3200: /home/buildroot-riscv-2018-10-20/output/host/usr/bin/riscv64-buildroot-linux-gnu-gcc -D_LARGEFILE_SOURCE -D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64 -Os -D_LARGEFILE_SOURCE -D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64 conftest.c -lrt >&5
/home/buildroot-riscv-2018-10-20/output/host/usr/lib/gcc/riscv64-buildroot-linux-gnu/7.3.0/../../../../riscv64-buildroot-linux-gnu/bin/ld: warning: libpthread.so.0, needed by /home/buildroot-riscv-2018-10-20/output/host/usr/riscv64-buildroot-linux-gnu/sysroot/usr/lib64/lp64d/librt.so, not found (try using -rpath or -rpath-link)
/home/buildroot-riscv-2018-10-20/output/host/usr/riscv64-buildroot-linux-gnu/sysroot/usr/lib64/lp64d/librt.so: undefined reference to `__pthread_barrier_wait@GLIBC_PRIVATE'
/home/buildroot-riscv-2018-10-20/output/host/usr/riscv64-buildroot-linux-gnu/sysroot/usr/lib64/lp64d/librt.so: undefined reference to `pthread_attr_setstacksize@GLIBC_2.27'
/home/buildroot-riscv-2018-10-20/output/host/usr/riscv64-buildroot-linux-gnu/sysroot/usr/lib64/lp64d/librt.so: undefined reference to `__pthread_barrier_init@GLIBC_PRIVATE'
/home/buildroot-riscv-2018-10-20/output/host/usr/riscv64-buildroot-linux-gnu/sysroot/usr/lib64/lp64d/librt.so: undefined reference to `__pthread_unwind@GLIBC_PRIVATE'
/home/buildroot-riscv-2018-10-20/output/host/usr/riscv64-buildroot-linux-gnu/sysroot/usr/lib64/lp64d/librt.so: undefined reference to `pthread_create@GLIBC_2.27'
/home/buildroot-riscv-2018-10-20/output/host/usr/riscv64-buildroot-linux-gnu/sysroot/usr/lib64/lp64d/librt.so: undefined reference to `pthread_sigmask@GLIBC_2.27'
/home/buildroot-riscv-2018-10-20/output/host/usr/riscv64-buildroot-linux-gnu/sysroot/usr/lib64/lp64d/librt.so: undefined reference to `pthread_once@GLIBC_2.27'
/home/buildroot-riscv-2018-10-20/output/host/usr/riscv64-buildroot-linux-gnu/sysroot/usr/lib64/lp64d/librt.so: undefined reference to `__shm_directory@GLIBC_PRIVATE'
/home/buildroot-riscv-2018-10-20/output/host/usr/riscv64-buildroot-linux-gnu/sysroot/usr/lib64/lp64d/librt.so: undefined reference to `pthread_detach@GLIBC_2.27'
/home/buildroot-riscv-2018-10-20/output/host/usr/riscv64-buildroot-linux-gnu/sysroot/usr/lib64/lp64d/librt.so: undefined reference to `pthread_cancel@GLIBC_2.27'
/home/buildroot-riscv-2018-10-20/output/host/usr/riscv64-buildroot-linux-gnu/sysroot/usr/lib64/lp64d/librt.so: undefined reference to `__pthread_get_minstack@GLIBC_PRIVATE'
collect2: error: ld returned 1 exit status
fabricio7p
(1 rep)
Jun 15, 2020, 11:56 PM
• Last activity: May 15, 2025, 06:05 AM
0
votes
1
answers
43
views
flock not working between forks on the same fd
I am working on a process that forks several times. To debug it, I am using a debug file for which I open a fd and which stays the same for all child forks. Then I have a function print_debug, that will print to that fd. Now when the main process and the childs are printing at the same time, the out...
I am working on a process that forks several times. To debug it, I am using a debug file for which I open a fd and which stays the same for all child forks. Then I have a function print_debug, that will print to that fd.
Now when the main process and the childs are printing at the same time, the output is intertwined in the debug file. I tried to solve that via a
flock(fd, LOCK_EX)
, but that seems to have no effect. Here is an excerpt from the print_debug function:
void print_debug(int fd, char *msg)
{
flock(fd, LOCK_EX);
print_debug2("... LOCK ACQUIRED ...");
... printing msg ...
flock(fd, LOCK_UN);
}
Now when several forks print at the same time, the output looks like this:
--12692-- ... LOCK ACQUIRED ...
--12692-- fork no wait with fd_in 4, fd_out 1 and fd_close
----121269694-2-- - ..... . LOLOCKCK A ACQCQUIUIRERED D .....
.
----121269694-2-- - exriecghutt e sitrdeee o
f pipe started
--12694---- 12.69..2- - LO..CK. ALOCQCUIK RACED Q..UI.
RE--D 12..69.4-
- --fd12 69ou2-t- ifs orck urwreaintt
ly: 1
----121269692-4-- - ...... L LOCOCK K ACACQUQUIRIREDED . .....
----121269692-4-- - fofdrk o nuto owan itcm wdit ch atfd i_is n cu0,rr fend_tlouy:t 15
and fd_close
--126--9412--69 .6-..- L..OC. K LOACCKQU AICQREUD IR..ED. .
.--.
12--69124-69- 6-er- rnexo ec2
ute tree
--1269--412--69 6-..- . ..LO.CK ALOCCKQU IRACEQUDIR ED.. ..
.--.
12--6129694-6- --c fmdd_e oxutec iuts edcu rrfrenomtl y:ex ec5
Clearly, the printing of "lock acquired" overlap. I also controlled the return value of flock, which is always 0 (success).
Does flock work in a situation like this? Why do I still have the issues of garbled messages in the log file?
Bastian
(25 rep)
May 6, 2025, 08:09 PM
• Last activity: May 11, 2025, 03:36 PM
1
votes
0
answers
105
views
UDP multicast fails with "network unreachable" after static IP change on Linux 4.1
We have a requirement for UDP multicasting in our project using Linux 4.1 kernel with static ip address. Basic UDP multicasting by the use of the `sendto` function to send data works fine with device static ip 10.13.204.100; the issue comes when I change the ip address of the device to 10.13.204.101...
We have a requirement for UDP multicasting in our project using Linux 4.1 kernel with static ip address.
Basic UDP multicasting by the use of the
sendto
function to send data works fine with device static ip 10.13.204.100; the issue comes when I change the ip address of the device to 10.13.204.101 or to any other ip in the same series, the udp multicasting starts showing the error:
sendto: network unreachable
The UDP has been initialized by the following function:
int udp_init()
{
char multicastTTL = 10;
// Create UDP socket:
memset(&socket_desc, 0, sizeof(socket_desc));
socket_desc = socket(AF_INET, SOCK_DGRAM, IPPROTO_UDP);
if (socket_desc %d\nsocket_desc==>%d\n", udp_socket_fd, socket_desc);
/* Set the TTL (time to live/hop count) for the send */
// if (setsockopt(socket_desc, IPPROTO_IP, IP_MULTICAST_TTL, &multicastTTL, sizeof(multicastTTL)) %s:%d\n", __FILE__, __FUNCTION__, __LINE__);
return 1;
}
}
Once the ip has been changed, the UDP socket is closed by the instruction:
close(socket_desc)
Once again the udp_init
function (showed above) is used to initialize the UDP socket and then it is used the sendto
function to transmit the data but this causes the error:
sendto:network unreachable
thanks in advance
Rajesh
(23 rep)
Jan 4, 2023, 10:11 AM
• Last activity: Apr 24, 2025, 12:17 PM
7
votes
2
answers
4145
views
mmap: effect of other processes writing to a file previously mapped read-only
I am trying to understand what happens when a file, which has been mapped into memory by the `mmap` system call, is subsequently written to by other processes. I have `mmap`ed memory with `PROT_READ` protection in "process A". If I close the underlying file descriptor in process A, and another proce...
I am trying to understand what happens when a file, which has been mapped into memory by the
mmap
system call, is subsequently written to by other processes.
I have mmap
ed memory with PROT_READ
protection in "process A". If I close the underlying file descriptor in process A, and another process later writes to that file (not using mmap
; just a simple redirection of stdout to the file using >
in the shell), is the mmap
ed memory in the address space of process A affected? Given that the pages are read-only, I would expect them not to change. However, process A is being terminated by SIGBUS
signals as a result of invalid memory accesses (Non-existent physical address at address 0x[...]
) when trying to parse the mapped memory. I am suspecting that this is stemming from writes to the backing file by other processes. Would setting MAP_PRIVATE
be sufficient to completely protect this memory from other processes?
user001
(3808 rep)
May 19, 2019, 10:12 PM
• Last activity: Apr 22, 2025, 01:04 PM
0
votes
1
answers
3259
views
Named pipe buffer after process end
I am creating named pipes in Ubuntu 18 and 16 environments in C language using gcc as compiler (`mkfifo()` and `open()`). One of the things I noticed that the named pipes remain in the filesystem after the process ends. My process is a endless process that runs in a `while(1)` loop because of my req...
I am creating named pipes in Ubuntu 18 and 16 environments in C language using gcc as compiler (
mkfifo()
and open()
). One of the things I noticed that the named pipes remain in the filesystem after the process ends. My process is a endless process that runs in a while(1)
loop because of my requirements and the only way to exit is ctrl-c or the kill
command in linux. I might add a ctrl-c signal to properly handle these situations but this is not the question.
Given that the named pipe remains in the filesystem (for example /tmp/named_pipe1
), do I need to check if the named pipe exists in the filesystem and delete it in the beginning of the process (because the file persists in the system), or is it redundant because even the file stays in the filesystem, it's buffer is deleted and I can use it like a new fresh fifo ? Because I don't want the fifo buffers to be mixed when I ctrl-c exit the previous run of the code and start the new one. I require an empty buffer when I restart the code.
**Note:** The system is not restarted between the runs of the process. Just the process is re-run.
Thanks in advance.
Max Paython
(101 rep)
Jan 25, 2020, 09:47 PM
• Last activity: Apr 22, 2025, 09:05 AM
Showing page 1 of 20 total questions