Skip to main content

Questions tagged [unix]

Unix is a multitasking, multi-user computer operating system originally developed in 1969 by a group of AT&T employees at Bell Labs.

Filter by
Sorted by
Tagged with
6 votes
3 answers
185 views

Copy a file portably across UNIX and UNIX-like systems with POSIX API (modeled after Boost's copy_file())

Overview: Following the POSIX API, there are 2 versions of the function: unix_copy_file(), and unix_fcopy_file(). One works with ...
Harith's user avatar
  • 9,687
7 votes
2 answers
716 views

Wrappers around write() and read() and a function to copy file permissions

Below follows wrappers around read() and write() that retry when interrupted by a signal (the case where the return value is -1 ...
Harith's user avatar
  • 9,687
1 vote
0 answers
42 views

Determining the value of PATH_MAX on UNIX-like systems

Below is the approach taken in the function allocpath() in the book "Advanced Programming in Unix Environment", which I have modified to simply determine ...
Harith's user avatar
  • 9,687
3 votes
2 answers
166 views

Get Terminal Size, Enable and Disable Terminal Raw Mode without NCURSES

I searched around and found these 7 ways to determine the width and height of the terminal: ...
Harith's user avatar
  • 9,687
3 votes
3 answers
349 views

Append Buffer for Buffering Small write(2) Calls

The purpose of this is written in the comment below (it is meant to be used in a text editor): abuf.h: ...
Harith's user avatar
  • 9,687
4 votes
2 answers
83 views

Find the Size of a File in a Portable Manner (revision)

This is a follow up to Find the Size of a File in a Portable Manner. What's new: The fast version (POSIX stat()) does not change the position indicator of the ...
Harith's user avatar
  • 9,687
5 votes
2 answers
957 views

An Implementation of UNIX wc shell utility

The implementation doesn't support the "-m" flag, and only works with ASCII, and has rather terrible output formatting in comparison with GNU's implementation of wc. Code: ...
Harith's user avatar
  • 9,687
4 votes
1 answer
184 views

Find the Size of a File in a Portable Manner

There's no function in the Standard C Library to determine the size of a file. The POSIX Standard has stat()/fstat() which are ...
Harith's user avatar
  • 9,687
9 votes
3 answers
2k views

Executing a shell command OS-independently

The goal of the code is to convert a Graphviz DOT file to an SVG file, and it achieves this by creating a child process and executing the "dot" command. ...
Harith's user avatar
  • 9,687
2 votes
1 answer
183 views

minitalk project using Rust | Communication between process using UNIX Signals

I am trying to build minitalk project from 42 school using Rust instead of C. This is a communication program between a client and a server. Both are process. To achieve this I am only allowed to use ...
byk's user avatar
  • 21
2 votes
2 answers
154 views

Wait for child while polling file descriptor with self-pipe controlled by different threads

I am working on a personal project, and one of the things it does is to call a blocking operation on a file descriptor while a forked+exec'ed child process is running. It needs to know when the ...
Seninha's user avatar
  • 171
3 votes
3 answers
141 views

Follow up: A chat server using the select() API

This is a follow up to my last question: Multiperson chat server using the select() API Changes: After much fine critique, I made the following changes to the code: Removed redundant casts and ...
Harith's user avatar
  • 9,687
11 votes
2 answers
1k views

Multiperson chat server using the select() API

I followed the Beej's Guide to Network Programming. The program acts like a multi-user chat server. One connects and sends a message to the server, which is forwarded to all that are connected. There'...
Harith's user avatar
  • 9,687
1 vote
1 answer
31 views

Multistage Dockerfile to build a C project and copy things over to second stage

I wrote this Dockerfile (multi-stage) where the first stage builds the project and in the second stage we just copy the stuff over. I am wondering can I please get some feedback? more specifically the ...
Node.JS's user avatar
  • 429
4 votes
1 answer
94 views

Recursively Copy Dotfiles from Git Repo to New System's Home Directory

I manage my dotfiles in a github repo. The idea would be that I could clone the repo if I ever have to develop on a new system and symlink them to the home ...
Jordan Mandel's user avatar
4 votes
1 answer
52 views

Task manager with dependencies (revisited)

This is a new version of the todo(1) utility I published some time ago. Now I use julian days rather than time_t to hold time; and the topological sorting is ...
phillbush's user avatar
  • 864
1 vote
2 answers
143 views

Low level tcp socket

Since I am a Unix newbie, I wanted to know if the code reflects the "unix" style and if there is something to add for it to be robust. P. S. I hope I am not overusing ...
Prakhar Srivastava's user avatar
9 votes
2 answers
707 views

Task manager with dependencies

todo(1) is a program that lists the next tasks in decreasing order of urgency (most urgent tasks first). "Next" tasks are those which are not blocked by a task it depends that is still not ...
phillbush's user avatar
  • 864
0 votes
1 answer
196 views

Unix batch job execution from BDD automation framework

As part of my testing, I have to connect to Unix server using putty and execute few unix jobs. Feature file Steps for test scenario: ...
Sh87's user avatar
  • 89
3 votes
1 answer
290 views

Writing a tail command clone

I'm reading Bruce Molay's book on Unix programming, and as an exercise I've implemented a copy of the tail command. My approach goes over the entire file once, to ...
albert's user avatar
  • 133
2 votes
1 answer
97 views

Rsync helper in C (Improved)

Last week I posted a previous version of this code. I improved the program and worked on it for a few days and I would love to get reviews, feedback and tips so I could learn more and more from you ...
yan_kh's user avatar
  • 77
3 votes
1 answer
99 views

Programming Pearls -- Column 1: Sorting unique numbers with bitfield

I've implemented a simple program to sort an input of unique numbers given as decimals on a separate line. The idea is, since all numbers are unique, to use a (long) bitfield where a 1 on index n ...
ljrk's user avatar
  • 889
3 votes
1 answer
214 views

UNIX cp multithreaded implementation in C

I recently finished a high school project of mine for a class revolving around creating my own multithreaded implementation of the "cp" terminal command in UNIX systems. I am seeking for ...
user avatar
4 votes
1 answer
360 views

Huffman encoding as Unix style command line utility

After watching Tom Scott explain Huffman coding in this YouTube video, I wanted to implement it myself. I want to use this project to further my understanding of Python. Additionally this tool should ...
endofline's user avatar
  • 143
4 votes
2 answers
489 views

Implementation of portscanner for a host

I have tried to check whether the ports of a host from port 0 to port 1023 is open or not. Could someone please review this code and provide feedback. ...
Paul's user avatar
  • 297
3 votes
1 answer
251 views

Finding the class to which the IP address belongs

I have tried the code for finding the class of the IP address the user inputs, and printing the network and the host bits in the IP address. Could someone please review this approach and provide ...
Paul's user avatar
  • 297
8 votes
4 answers
507 views

Implementation of system() function in Linux using fork() , exec() and waitpid() system calls

I have written the code for implementation of system() function using fork(), exec() and waitpid(). Could someone please review this code and provide feedback. Thanks a lot. ...
Paul's user avatar
  • 297
4 votes
2 answers
78 views

Implementation of cp program that prints the number of bytes copied

I have written the code for implementation of the cp program that prints the number of bytes copied when the user presses Ctrl-C. Could someone please review this code and provide feedback. Thanks a ...
Paul's user avatar
  • 297
2 votes
1 answer
44 views

Reproduce the system() function of linux

My mentor says to reproduce the system() function of Linux exactly as given in the man pages. I have written the below code. Could someone review this code and provide me any suggestions for ...
Paulson Raja L's user avatar
5 votes
2 answers
2k views

Menu for X11 using Xlib in C

I am learning the xlib library and I made a xmenu utility in order to practice it. It receives as input a menu specification where each line is a menu entry. Each line can be indented with tabs to ...
phillbush's user avatar
  • 864
2 votes
1 answer
71 views

Trim trailing lines and remove blank lines in C

This simple program, that I call trim(1), trims trailing lines and, if the flag -l is passed as an argument, it also removes ...
phillbush's user avatar
  • 864
2 votes
1 answer
79 views

The code reads from a specified offset to the specified number of bytes in a file

The code reads the specified number of bytes from a specified offset in a file, I have handled the partial reads and bytes > buf_size conditions. Could anyone review the code? and say whether the ...
Paulson Raja L's user avatar
-2 votes
1 answer
73 views

The code reads the file from the specified offset to the specified number of bytes. How to handle errors of partial reads in reading a file [closed]

I could like to read a file from a specified offset to a certain number of bytes in a file. I would pass the filename, the offset, the number of bytes as an argument. The constraint is should use only ...
Paulson Raja L's user avatar
4 votes
2 answers
212 views

Bash code to install bootstrap in a Ruby on Rails repository

Wrote some code to install bootstrap (latest) in a newly created rails application. update: fixed a typo ...
american-ninja-warrior's user avatar
2 votes
0 answers
47 views

Outputting a standalone shell script from arguments

I am solving an exercise. Essentially, it's a shell script that takes in file and/or directory arguments and outputs another (standalone) shell script that outputs these files, including any directory ...
Elena Andreea Abig's user avatar
3 votes
1 answer
414 views

Linux HDD/CPU Temperature Logging Bash Script to run every minute in crontab

I wrote a simple script to log HDD and CPU temps to a log file. If those temperatures reach a threshold, it will shutdown the server. I also made the script make sure the log files don't get over a ...
brandontaz2k2's user avatar
3 votes
0 answers
43 views

Application uniqueness and unilateral IPC on Unix

This program Detects application uniqueness, if the application is a unique/primary instance, it launches a server, otherwise a client over a Unix domain socket. Client will send a message that will ...
noconst's user avatar
  • 131
3 votes
1 answer
87 views

Code dealing with files and separate lines in them

I have been using similar piece of code since a while. I have read some issues regarding treating mapped memory as a string. I am not sure about that though, so I just use ...
Mihir Luthra's user avatar
4 votes
0 answers
505 views

tar-backup V1.01 - backup script for Linux (full and differential backups)

The backup script itself. Make it executable and place it somewhere in your path: ...
xxxLCxxx's user avatar
4 votes
4 answers
1k views

Unix chat server making communication between terminals possible

This Server handles clients communicating with each other. Because I was not willing to actually give every client a name, they are named by their socket's file descriptor. This is my first ...
TVSuchty's user avatar
  • 595
2 votes
0 answers
194 views

Blocking serial port C library

I am planning to write a reasonably feature rich serial library but wanted to cut my teeth on something fairly basic. This serial library is fairly simple. It is a thin wrapper on the UNIX open, ...
arcomber's user avatar
  • 2,449
3 votes
1 answer
160 views

Pidfile single process instance mechanism

I'm writing a system daemon in Rust that may be started by the user manually. Only one instance of the daemon should be running at a time so I have created a pidfile locking mechanism to prevent ...
Fyrn's user avatar
  • 33
3 votes
1 answer
649 views

checksum hash verification functions for bash scripts

just a little script, or a bit of a template of one that I used to submit an assignment. I believe it all works fine, I just wanted to give it to other people, and get some feedback on it; maybe make ...
voices's user avatar
  • 767
2 votes
3 answers
72 views

Command line test runner

This is a simple program to run a command-line program with given parameters and verify that it writes the expected output to stdout or stderr. The specification file is passed as the first argument. ...
User319's user avatar
  • 1,132
2 votes
0 answers
37 views

Script to report disk usage

I am trying to see how I can speed up the below script that reports disk usage. The timed find command towards the end is the problematic line that I am trying to ...
user186743's user avatar
2 votes
1 answer
69 views

Making a disk usage breakdown

I'm looking for a better way of doing this code I made. I work for tech support and one of the biggest questions I am asked is: "Hey, how did my disk get so full in my VPS?" I am aiming for output ...
Charles Wilson's user avatar
3 votes
0 answers
116 views

TextFileConvert - dos2ux and ux2dos in VB.NET

This provides text file conversion capabilities like the common Unix utilities "ux2dos" and "dos2ux". I needed the capability to perform Unix text file conversions, round trip, within a VB.NET ...
HackSlash's user avatar
  • 402
6 votes
2 answers
372 views

Rot13 Unix Filter in C

I'm trying to brush up on some C basics (it's been ten years since I've programmed in C) and am working on a simple Rot13 program as a Unix filter. Any suggestions on how to improve it would be ...
Gregory Gelfond's user avatar
2 votes
1 answer
600 views

Analog of unix word count (wc) in Java

I wrote implementation of unix console program word count "wc" in Java. Please evaluate it. Is there any better solution? ...
KXCompare's user avatar
9 votes
4 answers
1k views

Platform independent whereis function

I'm trying to write a platform independent Python (>=3.6.5) package that has a handful of java .class files that need to compiled using javac and run using ...
James Draper's user avatar