system-calls

How kernel know the difference between “int 0x80” and “int x”

ε祈祈猫儿з 提交于 2020-01-07 09:23:22
问题 int 0x80 is a system call, it's also 128 in hexa. why kernel use int 0x80 as interrupt and when i declare int x he knows it's just an integer named x and vice versa ? 回答1: You appear to be confused about the difference between C and assembly language. Both are programming languages, (nowadays) both accept the 0xNNNN notation for writing numbers in hexadecimal, and there's usually some way to embed tiny snippets of assembly language in a C program, but they are different languages . The

run a program in background with execvp system call in c

六月ゝ 毕业季﹏ 提交于 2020-01-07 05:45:13
问题 i'm writing a program that recieves a command name and arguments and optionally the string "bg" at the end , if the "bg" string is passed my program should execute the command with its arguments in background if not in foreground, here's my code: #include<sys/types.h> #include<sys/wait.h> #include<unistd.h> #include<stdio.h> #include<errno.h> #include <stdlib.h> #include <string.h> int main(int argc, char* argv[]) { pid_t pid; int state; if( (pid=fork())<0) { perror("\nError in fork"); exit(

how to find all files that dont have a matching file with the same name but different extension

坚强是说给别人听的谎言 提交于 2020-01-07 02:44:05
问题 i have a folder with over 1 million files. the files come in couples that only differ by their extension (e.g. a1.ext1 a1.ext2, a2.ext1, a2.ext2 ...) i need to scan this folder and make sure that it fulfills this requirement (of file coupling), and if i find a file without its match i should delete it. i've already done it in python, but it was super slow when it came to working with the 7-figure number of files.. is there a way to do this using a shell command/script? 回答1: Building on

Propagate system call interruptions in threads

感情迁移 提交于 2020-01-06 20:05:47
问题 I'm running two python threads ( import threading ). Both of them are blocked on a open() call; in fact they try to open named pipes in order to write in them, so it's a normal behaviour to block until somebody try to read from the named pipe. In short, it looks like: import threading def f(): open('pipe2', 'r') if __name__ == '__main__': t = threading.Thread(target=f) t.start() open('pipe1', 'r') When I type a ^C, the open() in the main thread is interrupted (raises IOError with errno == 4).

Can't exec No such file or directory

霸气de小男生 提交于 2020-01-06 09:53:29
问题 Merry Christmas to everybody. I'm having a dilemma with a perl script. In my script, I call another program with a system call, but I got this error: Can't exec "./Classificador/svm_classify": No such file or directory at Analise_de_Sentimentos_mudanca.pl line 463. I don't know if there is a problem in having my program in a different directory than the called program. Another curious thing is that this script used to run normally in Ubuntu 10.10. But now I've changed to Mint 14. Is it

System call from Simulink possible?

江枫思渺然 提交于 2020-01-05 23:58:12
问题 Is it possible to do a system call from Simulink? I haven't found it in documentation, but maybe there is a workaround. Or, it can be as easy as an function call. 回答1: You should be able to use an Embedded MATLAB Function Block to run a MATLAB function from Simulink. Within this function you can make a call to the SYSTEM function to execute an operating system command. 回答2: Yes, I do believe this is possible through S-Functions. Unfortunately, you must drop down to C or C++ and deal with a

System call from Simulink possible?

醉酒当歌 提交于 2020-01-05 23:58:06
问题 Is it possible to do a system call from Simulink? I haven't found it in documentation, but maybe there is a workaround. Or, it can be as easy as an function call. 回答1: You should be able to use an Embedded MATLAB Function Block to run a MATLAB function from Simulink. Within this function you can make a call to the SYSTEM function to execute an operating system command. 回答2: Yes, I do believe this is possible through S-Functions. Unfortunately, you must drop down to C or C++ and deal with a

system() call behavior

这一生的挚爱 提交于 2020-01-05 08:01:28
问题 I am using system() call to start "tail -f". One thing I saw was that, invocation of tail takes 2 processes (I can see in ps): 1) sh -c tail filename 2) tail filename As man page says: system() executes a command specified in command by calling /bin/sh -c command. I guess, process 1) is inevitable, correct? I was just wondering if I can reduce number of processes from 2 to 1. Thanks in advance. 回答1: system always does sh -c command. If you want only one process, do system("exec tail -f"). 回答2

Change format of syscall event trace output to ftrace

雨燕双飞 提交于 2020-01-04 13:46:19
问题 I enabled ftrace event tracing for sys_enter_openat syscall. The respective output format given at events/syscalls/sys_enter_openat/format is print fmt: "dfd: 0x%08lx, filename: 0x%08lx, flags: 0x%08lx, mode: 0x%08lx", ((unsigned long)(REC->dfd)), ((unsigned long)(REC->filename)), ((unsigned long)(REC->flags)), ((unsigned long)(REC->mode)) As expected a sample output line to ftrace is something like msm_irqbalance-1338 [000] ...1 211710.033931: sys_openat(dfd: ffffff9c, filename: 5af693f224,

Prompting for user input in assembly ci20 seg fault

被刻印的时光 ゝ 提交于 2020-01-04 06:20:08
问题 I am currently working on a small program on a ci20 machine that prompt the user for a integer value then print the value to the screen. My current code .data prompt: .asciiz "Please enter an integer: " message: .asciiz "\nValue entered: " .text .global main main: addiu $sp, $sp, -4 # push stack sw $ra, ($sp) # save return address addi $v0, $0, 4 la $a0, prompt syscall # printing prompt addi $v0, $0, 5 syscall # get user input move $t0, $v0 # save input in $t0 move $a0, $v0 addi $v0, $0, 1 #