导航:首页 > 操作系统 > 64位linux汇编

64位linux汇编

发布时间:2024-10-26 12:57:29

A. Linux中 汇编 *char[] 如何定义使用,麻烦也给出汇编 execve系统调用的实例。

#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <sys/wait.h>
#include <string.h>
int my_system(char *ch)
{
pid_t pid = vfork();
if(pid < 0){
perror("pid");
}
if(pid == 0){

char *buf[]={"","-c","ls",NULL};
// execlp("/bin/sh","","-c",ch,NULL);
execve("/bin/sh",buf,NULL);
//第一个参数是一个完整路径,第二个是参数地址数组。第三个是环境变,没需要的话就NULL。
_exit(1);
}
else{
int status;
waitpid(-1,&status,0);
if(WIFEXITED(status) == 0){
printf("error");
fflush(stdout);
}

}

return 0;
}
int main(int argc, char * argv[])
{
while(1)
{
char cmd[100];
printf("cmd:");
fflush(stdout);
fgets(cmd, sizeof(cmd), stdin);
cmd[strlen(cmd) - 1] = 0;
my_system(cmd);
}
return 0;
}

阅读全文

与64位linux汇编相关的资料

热点内容
数据库查询系统源码 浏览:621
php5314 浏览:361
完美国际安装到哪个文件夹 浏览:672
什么app可以扫一扫做题 浏览:542
程序员编码论坛 浏览:928
淘点是什么app 浏览:662
中国高等植物pdf 浏览:456
51单片机时间 浏览:185
后台如何获取服务器ip 浏览:269
单片机流水灯程序c语言 浏览:237
程序员第二职业挣钱 浏览:242
运行里怎么输入服务器路径 浏览:844
pythonstepwise 浏览:513
刘一男词汇速记指南pdf 浏览:67
php认证级别 浏览:372
方舟编译啥时候推送 浏览:1013
php手机验证码生成 浏览:678
哲学思维pdf 浏览:19
凌达压缩机有限公司招聘 浏览:537
weblogic命令部署 浏览:40