Last active
January 12, 2023 16:36
-
-
Save davisp/767a5812195c0934a12ec39f6826dc34 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
g++ foo.cc | |
./a.out |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <fcntl.h> | |
#include <stdio.h> | |
#include <string.h> | |
#include <unistd.h> | |
#include <iostream> | |
int | |
main(int, char* []) | |
{ | |
char* buf = nullptr; | |
int fd = open("blargh.txt", O_WRONLY | O_APPEND | O_CREAT, 755); | |
ssize_t written = pwrite(fd, 0x0, 2147483647, 0); | |
std::cerr << "Wrote: " << written << std::endl; | |
std::cerr << strerror(errno) << std::endl; | |
} |
janl
commented
Jan 12, 2023
% ls -la blargh.txt
--wxr----x 1 jan staff 2147483647 Jan 12 16:22 blargh.txt
% ls -lah blargh.txt
--wxr----x 1 jan staff 2.0G Jan 12 16:22 blargh.txt
% g++ --version
Apple clang version 14.0.0 (clang-1400.0.29.202)
Target: arm64-apple-darwin22.1.0
Thread model: posix
InstalledDir: /Library/Developer/CommandLineTools/usr/bin
% g++ foo.cc
% ./a.out
Wrote: 0
Undefined error: 0
uname -a
Darwin MacBook-Pro.local 22.1.0 Darwin Kernel Version 22.1.0: Sun Oct 9 20:15:09 PDT 2022; root:xnu-8792.41.9~2/RELEASE_ARM64_T6000 arm64
% ls -alt blargh.txt
-rwxr----x 1 leipzig staff 0 Jan 12 09:31 blargh.txt
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment