Skip to main content

Questions tagged [posix]

Use this tag for code that is intended to be work on any system conforming to POSIX specifications.

3 votes
0 answers
133 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,462
7 votes
2 answers
712 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,462
1 vote
0 answers
39 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,462
3 votes
2 answers
104 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,462
3 votes
1 answer
72 views

A quine that clones itself and runs some more quines

This is a follow-up to: A Quine program in C, where today I received the following suggestion: Now, write the code so that the binary "clones" itself (makes a replica with an altered ...
Harith's user avatar
  • 9,462
3 votes
3 answers
340 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,462
2 votes
1 answer
43 views

Finding the Size of a File in a Portable Manner (revision 2)

This is a follow up to Find the Size of a File in a Portable Manner (revision). Changes made: The return value of fseek() and ...
Harith's user avatar
  • 9,462
4 votes
2 answers
81 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,462
4 votes
1 answer
180 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,462
5 votes
1 answer
194 views

Parsing command-line arguments with getopt in C++

I did not find anything to parse command-line arguments in C++ (which was surprising), so I fell back to getopt() which has served me well in C (I am currently not ...
Harith's user avatar
  • 9,462
9 votes
4 answers
2k views

Implementing a simple byte manipulation encryption

Can you kindly take a look at the code? Any suggestions regarding performance, readability, potential bugs, portability, security measures, etc. are highly appreciated. The code reads a character, a ...
user174174's user avatar
7 votes
7 answers
410 views

A simple shell in C

The M-Shell (msh) provides a basic command-line interface similar, and features some builtins (cd, exit, help, whoami, kill). ...
Harith's user avatar
  • 9,462
0 votes
1 answer
29 views

Yet another sh script to backup one directory

A single directory should simply be backed up with the zip tool, and the time of the backup should be preserved in the file name. I have written a Posix shell script for this. Can this script simply ...
Tobias Grothe's user avatar
13 votes
5 answers
3k views

Portable old-school filesystem tool

I recently made a tool called mkfh to create a FHS compliant filesystem structure. I aimed to make it as portable as possible, so I wrote it in C89 and also tried ...
Labricecat's user avatar
1 vote
2 answers
73 views

Script to prevent nested root shells (POSIX)

Script to prevent nested root shells shall do exactly as said, plus some niceties like an error message when someone runs it with some argument/option. ...
Vlastimil Burián's user avatar

15 30 50 per page
1
2 3 4 5
9