system-calls

Assembly Code keep showing segment fault

♀尐吖头ヾ 提交于 2019-12-13 08:44:34
问题 Why this assembly code assemble and link fine but show segment fault in runtime. Commented after the instruction to give a idea what I wanted to do. jmp short init action: pop esi xor eax, eax mov byte [esi+24], al ;null terminating the string. mov dword [esi+25],24 ;length of the string mov al,4 ;syscall write mov ebx,1 ;standard out lea ecx,[esi] ;<<---------- Unsure about this. probably load the address of the string to ecx mov edx,[esi+25] ;<<-- load edx with string length int 80h init:

Why strange behavior of fork system call? [duplicate]

北城余情 提交于 2019-12-13 07:27:14
问题 This question already has answers here : printf anomaly after “fork()” (3 answers) Closed 3 years ago . int main(void) { printf("abc"); fork(); return 0; } Output of this code is : abcabc Why is it printing twice, even when fork system call is after the printf statement? Ideone link 回答1: Because stdout is buffered, often line-buffered. And in your program the buffer is flushed only at exit time, or when returning from main (and that happens "twice" when fork don't fail). Try adding fflush

How to hook system calls of my android app

╄→尐↘猪︶ㄣ 提交于 2019-12-13 06:52:06
问题 I want to intercept the connect() system call and use my own custom implementation. The custom implementation will do some action like printing a log for simplicity and then call the system implementation further. I looked at Audrey's blog where the approach is to patch the PLT. But unfortunately this code is crashing when trying to change the address in the relocation table. After goggling a while i came across This already answered question. But the approach described here gives me the

Difference between User vs Kernel System call

南楼画角 提交于 2019-12-13 06:32:20
问题 A system call is how a program requests a service from an operating system's kernel. They can occur in user-mode and kernel-mode. What are differences? For example: Overhead System time 回答1: A system call is the way you transition between the application ("user mode") and the kernel. Syscalls are slower than normal function calls, but newer x86 chips from Intel and AMD have a special sysenter / syscall opcode to make it take just a hundred nanoseconds or so, give or take. 回答2: @Leo, Could you

Print MIPS Register Contents

拥有回忆 提交于 2019-12-13 02:48:25
问题 I am trying to print an unsigned integer value from a MIPS register as ASCII text to the console. In other words, let's pretend $a0 has "0x4ab3c823" in it. I want to print out "4ab3c823" to console in xSPIM. Here is my attempt. I keep getting the decimal values, not the ASCII. It's only a snipped of the entire program, so I cut out the rest. .data printspace: .space 8 .text printHex: move $t0,$a0 la $a0,printspace #Save address of 8 blank bytes to $a0 sw $t0,0($a0) #Copys the integer I want

System call time out?

丶灬走出姿态 提交于 2019-12-12 20:54:33
问题 I'm using unix system() calls to gunzip and gzip files. With very large files sometimes (i.e. on the cluster compute node) these get aborted, while other times (i.e. on the login nodes) they go through. Is there some soft limit on the time a system call may take? What else could it be? 回答1: The calling thread should block indefinitely until the task you initiated with system() completes. If what you are observing is that the call returns and the file operation as not completed it is an

MINIX: sys_call: ipc mask denied SENDREC from 1 to 1

孤人 提交于 2019-12-12 19:40:21
问题 In MINIX 3.2.1 , I want to create a new system call in VFS server which will be given a filename as a parameter and will print this certain file's inode number. So in order to retrieve the inode of the file by its name I want to use the default system call: int stat(char *name,struct stat *buffer) http://minix1.woodhull.com/manpages/man2/stat.2.html in the body of my new system call handler which is int mycall_1(void); inside `/usr/src/servers/vfs/misc.c But when I test the new system call,

How to load a dynamic library on demand from a C++ function/Qt method

我怕爱的太早我们不能终老 提交于 2019-12-12 19:19:45
问题 I have dynamic library created as follows cat myfile.cc struct Tcl_Interp; extern "C" int My_Init(Tcl_Interp *) { return 0; } 1) complile the cc file g++ -fPIC -c myfile.cc 2) Creating a shared library g++ -static-libstdc++ -static-libgcc -shared -o libmy.so myfile.o -L/tools/linux64/qt-4.6.0/lib -lQtCore -lQtGui 3) load the library from a TCL proc then I give command tclsh and given command % load libmy.so is there any C++ function/ Qt equivalent to load that can load the shared library on

How to correctly escape system calls from inside R

那年仲夏 提交于 2019-12-12 17:05:22
问题 I have several shell commands that I want to run in in R. I have tried system() but I have not find out how to do the right escaping even using shQuote. # works OK system('ls -a -l') but how I execute a command like perl -e 'print "test\n"' or curl --data-urlencode query@biomart.xml http://biomart.org/biomart/martservice/results inside R? update: In the case of commands like the perl example I do not know how to do the escaping of quotes as it needs to be quoted as string but already use both

how linux's alarm() is handled by kernel

可紊 提交于 2019-12-12 15:07:54
问题 I was reading about how the alarm() call works on the linux. alarm(5) would send a SIGALRM in a minimum of 5 seconds to the process which has made this call. The alarm is caused at that moment thanks to a down counter which is set by the kernel reaching zero. My doubt is here - we can have N number of processes which make an alarm call, and there is one down counter in the system available for this purpose. So the kernel has to keep track of all the processes it has to send a signal to, with