Trying to understand read() in Ubuntu

I am trying to learn read() system call using the following code that reads from the stdin and outputs what was read to the stdout : # include <unistd.h> # include <stdio.h> int main() { int b=10; char buff [b]; int n= read(0,buff,b); write(1,buff,n); printf("%d \n",n); } As it is clear the max. bytes to… Read More Trying to understand read() in Ubuntu

Why does NASM system call number perform 2 different operations despite specifying the same call number

I have the following ‘hello world’ code written in NASM x86_64 assembly: section .data msg db "Hello World", 0xa msg_L equ $-msg section .text global _start _start: mov eax, 4 ; sys_write call mov ebx, 1 ; stdout mov ecx, msg mov edx, msg_L int 0x80 ; call kernel mov eax, 1 ; sys_exit call… Read More Why does NASM system call number perform 2 different operations despite specifying the same call number

How to fix data write or read using pipe in c program is giving wrong output?

I am trying to get an integer input in the child process and send it to the parent process using pipe() but I receive garbage values every time in the parent process. #include <stdio.h> #include <unistd.h> #include <stdlib.h> #include<sys/wait.h> int main(int argc, char *argv[]) { pid_t pid; int fd[2]; char *args[] = {"", NULL}; int… Read More How to fix data write or read using pipe in c program is giving wrong output?