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.
134
questions
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 ...
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 ...
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 ...
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:
...
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:
...
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 ...
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:
...
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 ...
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.
...
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 ...
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 ...
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 ...
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'...
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 ...
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 ...
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 ...
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 ...
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 ...
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:
...
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 ...
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 ...
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 ...
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 ...
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 ...
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.
...
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 ...
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.
...
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 ...
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 ...
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 ...
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 ...
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 ...
-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 ...
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
...
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 ...
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 ...
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 ...
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 ...
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:
...
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 ...
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, ...
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 ...
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 ...
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. ...
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 ...
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 ...
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 ...
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 ...
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?
...
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 ...