I was wondering what exactly happens after the execution of a handler on a signal in C, more specifically on the SIGCHLD signal. I’m actually building a shell and I need to do this: User enters a command with “&” as the last argument A new process is created with fork The parent process returns to the main function and
Tag: system-calls
How to kill a process in a system call?
I found out that sys_kill can be used to kill process from a system call, but when i compile the following code, i get the following error: Answer It is often not possible to call the entry point of a system call from the kernel, since the API is for use from user space. Sometimes the functionality is provided in
gdb catch syscall condition and string comparisson
I would like to catch a system call (more specifically access) and set a condition on it based on string comparison (obviously for arguments that are strings). Specific example: when debugging ls I would like to catch access syscalls for specific pathnames (the 1st argument) int access(const char *pathname, int mode); So far, I have succeeded in manually inspecting the
When should syscall function be used instead of glibc wrapper?
man page of syscall says, “it is useful when there is no wrapper function in c library”. If wrapper function is available, Is it always better to use wrapper function ? If not, when should prefer syscall over it? Answer Never. The only situation where you should ever consider using syscall() is to invoke a system call that doesn’t have
sys_ functions in syscalls.h are undefined
I’m just making a kernel module. And I meet this warnings: How can I fix this problem? This is my codes: And my workspace is Ubuntu 3.13.0-66-generic. I need to use file descriptor. So, I can’t use filp_ functions(like filp_open). Edit1: My Makefile: obj-m += NAME.o Answer Calling system calls(sys_* functions) from the kernel code is not a good idea.
assembly function segfault at return (nasm x64)
My asm function segfaults at return. Here is the function prototype : void ft_cat(int fd); Basically it get a fd from a C main and act like cat shell command. I get no problem if I removed read and write parts so maybe the problem is around syscalls. I just can’t tell. I already spent hours and hours looking for
Accessing errno.h in assembly language
I want to access errno present in errno.h in assembly language in order to handle errors of write function call. I found somewhere that make call to _error in assembly language for this purpose but it is throwing errors as : My assembly code : ExitNewShell.asm How to access errno in assembly language? Answer You’re making x86 Linux syscalls from
system call open() creating executable
So my code creates and writes to the out_file properly. However, the file is an executable for some reason. I think the fault is in my open() call but I can’t seem to find why. Answer man 2 open explains why: So if you want a file that’s not executable, you can use: 0666 will suggest read/write for all (equivalent
How to view the list of c library functions in Linux? [closed]
Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers. We don’t allow questions seeking recommendations for books, tools, software libraries, and more. You can edit the question so it can be answered with facts and citations. Closed 6 years ago. Improve this question I’m a newbie in Linux programming. I found that the way
System calls : difference between sys_exit(), SYS_exit and exit()
What is the difference between SYS_exit, sys_exit() and exit()? What I understand : The linux kernel provides system calls, which are listed in man 2 syscalls. There are wrapper functions of those syscalls provided by glibc which have mostly similar names as the syscalls. My question : In man 2 syscalls, there is no mention of SYS_exit and sys_exit(), for