Skip to main content
The 2024 Developer Survey results are live! See the results

All Questions

Tagged with
-1 votes
1 answer
82 views

Why lines variable is 0?

I've created wc like program and when i tried to do line counting, it shows as 0. The code: #include <stdio.h> #include <stdlib.h> FILE* file; int main(int argc, char* argv[]) { //...
TeenProgrammer's user avatar
-3 votes
1 answer
121 views

How to interface with a UNIX port? [closed]

I have encountered this same question in numerous forms over the past year, and have not been able to find the solution I am after. As the question has yet again reared its head, I am asking here with ...
BrownianBridge's user avatar
-2 votes
3 answers
141 views

if(fork()) and if(!fork()) - how do they work?

Let's say we have the following: pid_t pid; pid = fork(); if(pid == 0) { if(fork()) printf("A"); else printf("B"); printf("C"); } else { ...
RhoThanos's user avatar
1 vote
1 answer
60 views

For wrappers around syscalls that retry on EINTR, how many times does retrying make sense?

Often syscalls like write(2), read(2), close(2) et cetera fail due to being interrupted by a signal with the errno value EINTR (say the size of the terminal window changed and SIGWINCH was received), ...
Harith's user avatar
  • 7,235
2 votes
0 answers
54 views

Using ptrace to get arguments and return value of child's system calls

I'm trying to better understand how strace works by trying to write a much simplified version of strace, but I'm having difficulty getting the correct return value of system calls. Could someone ...
user2374991's user avatar
0 votes
1 answer
44 views

Reverse name lookup with getnameinfo() doesn't work with custom sockaddr_in6

I wrote the following code and expect it to return the address of google.com. However, it returns me an empty string at the end. What do I need to fix to make it work? getnameinfo() gives me the error ...
Artyom Gevorgyan's user avatar
0 votes
0 answers
104 views

Why does my simple HTTP server need two instances running in order to work?

Noob here. I have been following Beej's Guide to Network Programming and tried constructing an HTTP server following the style of code used in the book. I am running FreeBSD 14.0. My issue is that all ...
JoshHellauer's user avatar
0 votes
0 answers
31 views

Extracting CPU Vendor Name via cpuid on qemu-XV6 returns "Genuntelntel" on my AMD machine

I am running xv6 via QEMU on Ubuntu 20.04.6 via Windows WSL. I wanted to write a syscall to extract and print the CPU vendor name by editing the kernel code. Did the usual pleasantries, wrote up a ...
Hash's user avatar
  • 146
0 votes
2 answers
58 views

Message Queues IPC does not work properly

this code implements a simple client-server communication system using message queues in C. local.h #include <stdio.h> #include <sys/types.h> #include "sys/ipc.h" #include <...
kaanyvz's user avatar
  • 33
4 votes
0 answers
75 views

Why getsockopt with SO_SNDBUF for a TCP socket gives a 1/13 of the value at /proc/sys/net/core/wmem_default?

While doing some exercises about sockets, I wrote the code below. const int socketfd = socket(AF_INET, SOCK_STREAM, 0); int tcprcvbuf; socklen_t tcprcvbuflen = sizeof(tcprcvbuf); ...
Lady Idiot's user avatar
1 vote
1 answer
60 views

UNIX Signal mistreated for communication suddenly receives from pid 0

I am doing a test setup where I use UNIX signals for communication. The following code uses SIGUSR1 and SIGUSR2 to transfer a string from a client process to a server process that will listen for ...
Tilidien's user avatar
2 votes
0 answers
38 views

Trace function calls of child process using /proc/pid/maps and ptrace

I am trying to code a tracer for any C program that displays all the functions that are being called. Here is an example: $./tracer toto.out + Entering main at 0x123456789 'I am in Toto's main' + ...
Julian52575's user avatar
1 vote
0 answers
59 views

Memory usage continuously increases during socket communication with pollset() on AIX

I am managing a server process in an AIX 7.1 environment that performs socket communication using pollset(). We have observed that memory usage(vsz) intermittently increases and fails to decrease, ...
polxz's user avatar
  • 11
0 votes
0 answers
35 views

Read a single char value to stdin without pressing enter on keybard in C in mac os [duplicate]

I am using mac os with xcode-select version 2406 I am trying to find a way to Read a char value to STDIN without pressing enter or return key on keyboard in C. I know on windows we have getch function ...
Pritam's user avatar
  • 7
1 vote
2 answers
61 views

Why listen() (before accept() is called) is enough for an application to complete a 3 way handshake?

I am debugging a very basic tcp server in C at Linux. I stopped the execution right before the line where accept() is called. To my suprise, when the client sends a SYN, tcpdump shows that the server ...
Lady Idiot's user avatar

15 30 50 per page
1
2 3 4 5
356