问题标签 [execvp]

For questions regarding programming in ECMAScript (JavaScript/JS) and its various dialects/implementations (excluding ActionScript). Note JavaScript is NOT the same as Java! Please include all relevant tags on your question; e.g., [node.js], [jquery], [json], [reactjs], [angular], [ember.js], [vue.js], [typescript], [svelte], etc.

0 投票
2 回答
956 浏览

c++ - Load user environment when executing process with execvp();

i have a daemon running which might spawn a Process on incomming connections. This is done using execvp() and fork().

The Problem is that the process should not run as root and the process is dependend on a correct user environment. So im seeking a way to load the user environment.

Currently the process is executed as another user by setting gid and uid. What i have already tried is using as command su -l user -c command, which did not work for some reason.

Does somebody have an idea how i can load the user environment (especially the $HOME variable)?

Thanks in advance.

0 投票
1 回答
132 浏览

c++ - 这段代码有什么问题?

我试图用这些参数调用 evecvp() :

我收到此错误:

使用类型转换尝试了所有排列,但无法使其正常工作。有什么问题?

0 投票
1 回答
2161 浏览

c - 实现 shell:execvp() 中的参数错误

最近,我正在尝试在 C 上进行良好的练习,现在我来执行命令了。它告诉我,我应该我们char**吗?但是我是不是有些概念错了。

请帮我。代码在这里

它在编译时给了我警告。但是如果我将 2D 数组更改为char**....

警告:从不兼容的指针类型传递 'execvp' 的参数 2 [默认启用] /usr/include/unistd.h:579:12:注意:预期的 'char * const*' 但参数的类型是 'char (*) [256]'</p>

0 投票
2 回答
7334 浏览

c - execvp 文件路径说明

我正在用 C 编写一个 shell,但我无法理解execvp(filepath,argv).

如果键入的用户想要ls -a在他们的当前目录中运行......比方说......在所述目录中运行的and/home/user1会是什么?filepathargvls

filepath执行命令的目录/home/user1还是命令的位置?/bin/ls

0 投票
1 回答
1045 浏览

c - C - 尝试将 /bin/ls 传递给 execvp 时出错

我正在开发一个需要能够使用 execvp 执行某些命令的 C 程序,我已经实现了这个:

execvp(arguments[0], arguments);

哪里arguments[]是一系列的刺。在大多数情况下,我的实现工作正常 - 例如,如果arguments{"touch", "somefile.txt"}touch则按预期调用命令。

但是,当我尝试将ls参数传递给 execvp 时{"/bin/ls", "-a", "."}, ls 函数会按预期打印目录列表,但也会打印错误

ls: cannot access GLIBC_2.0: No such file or directory

我不知道如何解决这个警告,谷歌搜索也没有任何结果。有什么想法有什么问题吗?

0 投票
1 回答
727 浏览

c - 叉子错误,C中的execvp?

我在使用 execvp 和 fork 时遇到问题。当我运行代码时,即使创建了文件,exec 也不起作用。它只是返回“错误地址”错误。此外,我运行它时不会出现 printf("in the child") 。我的代码如何在不打印“在孩子中”的情况下进入 execvp?

0 投票
1 回答
1672 浏览

c - 在 c 程序中使用 execvp 运行命令

我想用 execvp 运行这个命令

我创建了一个包含以下内容的选项卡:

当我这样调用 execvp 时:

我有这个错误:

当我使用编译文件时:

没有问题。

请注意,我的程序不像我那样编写它是为了简化。完整代码请访问http://pastebin.com/zQ8pwmZd

0 投票
1 回答
1089 浏览

c - Linux C getopt 在第一个未指定的参数后忽略

我想让程序完成“execvp(argv[1],argv+1);” 如果第一个参数未定义,但 getopt 解析所有以“-”开头的参数。如何忽略第一个未定义参数之后的所有参数?这可以使用getopt吗?目前,我有代码:

}

当你执行时,我得到:

我想做这样的;

等等......但我不知道。

0 投票
0 回答
246 浏览

c++ - 将字符串拆分为 char 数组指针

我正在使用用户输入作为参数传递给 execvp。如果我将其作为 execvp 的论据,它会起作用:

当我尝试将用户输入拆分到上面的数组中时,它不会让我将单词存储到数组中并出现以下错误:错误:无法在赋值中将 std::string {aka std::basic_string} 转换为 char

0 投票
4 回答
200 浏览

c - 前台执行

我无法execvp像工作方式一样system()工作。

当我使用代码时:

./file按预期运行并打印child->parent

但是当我尝试运行程序时:

我得到一个输出child->parentparent并且文件没有file在命令提示符中显示输出(从 生成)。

我在这里做错了吗?我实际上是在尝试file在前台运行并让父母等到它完成。