C is a general-purpose computer programming language used for operating systems, games and other high performance work and is clearly distinct from C++. It was developed in 1972 by Dennis Ritchie for use with the Unix operating system.

learn more… | top users | synonyms

-3
votes
0answers
33 views

How can we test POSIX compliance? [on hold]

If I want to test "POSIX compliance", can you help me script a test? I'm writing my own shell and I've scripted a test that succeeds, but my test cases are random and I don't know much about the ...
0
votes
0answers
26 views

How to know the depth of a path? [migrated]

I'm debugging my own C code, which allocates memory for the current path using getcwd. Valgrind reports a memory leakage: snprintf(shell_prompt, sizeof shell_prompt + sizeof cwd + 128, "%s: $ ", ...
0
votes
1answer
28 views

Can all of fork(), exec() and system() be wrong? [on hold]

I understand why it could be less than best practice if I write C code that executes shell commands by calling system() and that it's better to use exec and fork but then a very experienced C ...
0
votes
0answers
9 views

Is editline tab completion supposed to work? [migrated]

Is there a way for libedit (editline) to do tab completion if I use editline for a small shell? It seems that rl_parse_and_bind is not available if I include histedit.h - why doesn't it work? int ...
3
votes
3answers
194 views

POSIX compliance of the cd program?

Is globbing and shell expansion same thing? I'm learning C by writing a custom shell and I'm also learning POSIX. Now I wonder if it is POSIX compliance that cd - takes you back and that ~ means home ...
0
votes
1answer
38 views

Using Named Pipes in Bash created in a C Program

I have a C code that takes a rather large input. At every iteration, it processes a small chunk of it and it should send that processed chunk to S3 using curl. In the end, it will generate a number of ...
2
votes
2answers
40 views

How can I find out what linker flags are needed to use a given C library function?

Running example C code is a painful exercise unless it comes with a makefile. I often find myself with a C file containing code that supposedly does something very cool, but for which a first basic ...
1
vote
2answers
38 views

How to extract a function from file? [closed]

I am looking for a command to extract a C function from my code. It would be something like: $ grep -func "MyFunction" foo.c int MyFunction(int i) { return i+1; } I know we can extract it with ...
0
votes
0answers
8 views

Check current state of child process (not change of state) [migrated]

I want to check whether a child process is currently stopped or not (I'm using ptrace). Using waitpid with NOHANG doesn't work, because that only checks for a change of state since last time, not the ...
1
vote
0answers
16 views

Why does libcap use obfuscated pointer for cap_t [migrated]

Why is cap_t defined as _cap_struct *? What was the reasoning for obfuscating the pointer type and having libcap functions take/return cap_t when normal libc usage suggests they would take/return a ...
0
votes
0answers
12 views

openssh - Reading from a file [migrated]

In the openssh code (openssh-5.9p1/auth2.c) in the function input_userauth_request(int type, u_int32_t seq, void *ctxt) I'm trying to read my own file (tried using fopen, fread) but fopen fails ...
0
votes
0answers
19 views

Build location-independent GCC binaries

I have some problems with GCC. I want a portable version of GCC because the PC I use for programming cannot be connected to Internet due to some driver issues. So, I read an article on how to compile ...
0
votes
0answers
19 views

GCC Compile Error: /usr/bin/ld: cannot find -lsqlite3.lib [migrated]

I'm trying to compile a little C-program using SQLite3. I've already included the Header-File and converted the .dll file into a .lib file. The interesting thing is that on windows, gcc (CodeBlocks) ...
0
votes
0answers
10 views

Error with libraries after setting up Code::blocks to work as an arduino IDE

First of all I apologize in advance if this is the wrong community, you're welcome to advise me another one to post. I followed this guide: ...
0
votes
0answers
11 views

Error occured with USB modem

I have MPC8309 Tower Board and connected USB Modem to it and then established Async PPP on Modem, now I started applying ping from different terminal from my laptop by applying nat commands and ...
0
votes
1answer
73 views

Maintaining single binary across Debian distributions

We are currently migrating our system from Debian 6 to 8. The agenda is to try to maintain single binary across OS platforms (x86 based) However, I tried running a Debian 8–compiled binary in ...
1
vote
1answer
74 views

What is the number at the top for the results for ls -l? [duplicate]

When you type in ls -l, there is a number on the first line labeled "total 22037"? What does this number mean? I am attempting to write my own version of ls -l( in C), and how do I get this value or ...
0
votes
1answer
14 views

Busy /dev/gpio. I can shared it?

I need shared one device between two C applications. This device is a buzzer. I've try open this with O_NONBLOCK flag, but result is same: device or resource busy. Is there any possibility to use the ...
0
votes
0answers
20 views

How to call a device's power management methods in another way than during suspend to ram?

Let us consider the e1000e driver for an Ethernet card. This driver provide two power management methods .suspend and .resume to respectively turn off and turn on the card. Those methods are naturally ...
1
vote
1answer
73 views

Why do the Linux kernel headers contain references to nonexistent headers?

I'm trying to build IBCS (source here) on Ubuntu 15.10 (Linux 4.2.35). This module is obviously pretty old, because its CONFIG.i386 file gives gcc an option -m486, which doesn't exist anymore, but ...
1
vote
1answer
47 views

pkg-config output not working with makefile?

I'm trying to run the makefile, shown in this repo, which is a simple Wayland client. But when I run make, it seems that the output of $(WAYLAND) is blank, and it fails to compile due to not being ...
1
vote
0answers
43 views

Is the (Free)BSD Codebase ANSI Compliant?

Google does not seem to shed any light on this topic - But the question is quite simple: Is the FreeBSD (Or any BSD) CodeBase ANSI (c89) Compliant, or does it use c99, c11 or non-standard features ...
3
votes
1answer
49 views

No stdlib in UNIX v7?

Browsing through the v7 UNIX Sources I noticed there is no "stdlib" directory - further more using a v7 UNIX Emulator, there is no such file as <stdlib.h>. However functions like exit() and ...
1
vote
0answers
23 views

Unable to establish PPP on USB dongle?

I have USB Dongle and i am willing to setup ppp through the dongle. I have done following steps to setup ppp. 1.When i plugged the dongle into Ubuntu 14.04. It has been detected as the Mass ...
2
votes
1answer
36 views

non-reentrant libraries in shared memory?

I found this Q&A saying shared libraries can be shared between processes using shared memory. It seems like it would be impossible, though, to share code between processes without some pretty ...
1
vote
0answers
20 views

I2C Read unexplained data [closed]

I am trying to communicate with a PHY device using I2C primitives (read()/write()) in C language in user space. And i am getting some unexplained output in my program. First, the bus number is 2 and ...
0
votes
2answers
41 views

Parent process always printing output after child

Consider the following code running under Solaris 11.3: int main(void) { pid_t pid = fork(); if (pid > 0) { printf("[%ld]: Writing from parent process\n", getpid()); } if ...
1
vote
1answer
41 views

Location of executable file formed after compiling a C program

I have compiled my C source code using: gcc filename.c It got compiled, but I cannot see the executable in the same directory where my source code is. But when I compile my program using: gcc ...
1
vote
2answers
36 views

Run an executable as a service on a port

I have a C program (say a simple Queue system) which I compile and get an executable file. I want to run this executable as a service on a specific TCP port on a CentOS system which I can connect to ...
0
votes
0answers
101 views

Building Handbrake on Debian Jessie

I have found a web site that explains how to install Handbrake 0.9.9 on Jessie. The explanations there seem a bit outdated, because it advises to use SVN to get the sources, but Handbrake has switched ...
0
votes
1answer
36 views

How does one establish SIGRTMIN at run-time?

Reading up on signal(7) I can see that now: two, but once: three; signal numbers past 31 are reserved for use by the Real-time signal system and should not be used: Real-time Signals Linux ...
1
vote
3answers
80 views

Trouble with creating an empty file using C programming language in UNIX environment

I have recently started programming in UNIX environment. I need to write a program which creates an empty file with name and size given in the terminal using this commands gcc foo.c -o foo.o ./foo.o ...
0
votes
0answers
7 views

GDB not copying desired string (Buffer Overflow attempt)

Ok so I am trying to learn about buffer overflows and there is this simple program that is vulnerable of a BoF because it copies the first argument into a buffer of 5 characters. In the source code, ...
0
votes
1answer
40 views

How can I succesfully call the execv function? [closed]

I am trying to make a program that will copy file1 into file2 the following way: cp -i -p file1 file2 Now I call my executable copy and so by calling copy file1 file2 It will do the same thing ...
2
votes
2answers
67 views

Minimal Busybox/Linux Installation - Won't Run C

I'm trying my hand at creating a very minimal custom Busybox/Linux distro, a task that is admittedly above my head, but I figured I'd give it a shot. My issue is that whenever I try to run a C program ...
0
votes
1answer
45 views

How do kthreads actually work?

Need to implement DHCP server in kernel space. It's supposed to be a multithreading server, and I think I should use kthreads ( I'll be glade if you know better decision ). However I can't understand ...
-2
votes
2answers
15 views

Is the flag treated as string in c command argument? [closed]

say I have the following: #include <stdio.h> #include <string.h> int main(int argc, char *argv[]){ if (argv[1] == "-s") { printf("success\n"); } else{ ...
1
vote
0answers
91 views

error while compiling my first program in C language? [closed]

I am a newer user of Ubuntu I used to compile c file via Code Block in Win OS. But now I've created a simple program (hello ,world!). This is the code #include<stdio.h> /* demo.c: My first C ...
1
vote
2answers
40 views

Generate raw Ethernet frames with memory preloaded payloads at < 1 ms intervals

I am looking to generate raw Ethernet frames with payload that is preloaded into memory. The Ethernet frames (10-60 full frames) should be generated at 1 ms intervals with no exception. What would ...
2
votes
1answer
44 views

Compute total CPU usage of a PID namespace

I'd like to monitor the CPU usage for all processes in a particular PID namespace. I'd like to do it programmatically (C, if possible). I have an idea of how to do it, but I'd like to know if Linux ...
0
votes
0answers
20 views

openpty returning zero as master file descriptor

I am opening a pseudoterminal with openpty function. This will be used to redirect some data coming from a serial port into an external application (in this case, a GPS receiver). The fact is that ...
1
vote
1answer
22 views

Merging text file directories

I have two directories: Libc-825 and Libc-1044. Imagine that version 1044 is newer, but buggy. Is there a way to merge these file trees? I have there C sources with not so big differences. I have ...
-2
votes
1answer
56 views

What does the -p option do exactly with the cp command?

So I am trying to understand what is the significance of the -p option for the cp command. I opened the manual of the cp command and it says -p same as --preserve=mode,ownership,time stamps. But ...
0
votes
1answer
28 views

openSSL Key and Certificate

As far I know, in an authenticated SSL connection, both the client and server have private keys and provide their certificates (with the corresponding public keys) across the connection before ...
0
votes
2answers
52 views

Sleep system call and its time parameter

Let's say that we are writing a C program that calls the sleep() function. For instance, by calling sleep(7), the calling thread would be put to sleep for 7 seconds. My question is: Will the thread ...
6
votes
2answers
76 views

Get header of the C function from BASH

I want to get the header(s) that I need for a given C function - e.g. when I want to see what to include when I want to use fork(), I can type out man fork and see that it's #include <unistd.h>. ...
0
votes
1answer
241 views

Process tree using fork() [closed]

I am given the task of creating this process tree in C using fork, if and else: |_____1___ |___2__ | |_4_ | |_3_ | | | | | Or as a pstree like drawing: p(0)─┬─p(1)───p(3) ├─p(2) ...
-1
votes
1answer
33 views

IOCTL() Library for Windows [closed]

I am trying to cross compile my c code from debian linux to a windows platform. I have worked out most of the kinks but I am struggling with ioctl(). Windows doesn't seem to have a ioctl() equivalent ...
1
vote
1answer
202 views

Get output of `posix_spawn`

So I can run a process in Unix / Linux using POSIX, but is there some way I can store / redirect both the STDOUT and STDERR of the process to a file? The spawn.h header contains a deceleration of ...
2
votes
1answer
242 views

mount overlayFS as Read-Write FS

I want to mount my RO Filesystem using overlayFS - in order to use two layers FS (Lowerdir and Upperdir). I tried the following mounting command - mount -t overlayfs -o lowerdir=/,upperdir=/overlay ...