小编MOH*_*MED的帖子

如何用shell命令刷新

是否有相当于fflush()shell命令的C函数?

echo "kkkk"
flush <<< are there some command to execute to flush stdout?
Run Code Online (Sandbox Code Playgroud)

c linux bash shell

6
推荐指数
1
解决办法
7724
查看次数

如何将系统日志输出发送到标准输出?

我在我的程序中使用 syslog 来生成日志消息。

有没有办法将我的程序的系统日志输出发送到 stdout ?

我不想使用tail命令查看我的程序日志,我想直接在控制台上查看它

c linux bash shell syslog

6
推荐指数
2
解决办法
2万
查看次数

内核模块参数更改(使用/ sys/module)

我对linux中的/ sys/module /有一些疑问

1)/ sys/module是否包含内核的所有模块

2)/ sys/module/xxx /参数是否包含内核模块xxxx的所有参数

3)/ sys/module/xxx/parameters/yyyy是否包含内核模块xxxx的参数yyyy的实时值

4)如果在给定内核模块中更改参数,如何在RealTime中检测此更改?我想开发一个C应用程序(用户空间)或shell脚本,它实时检测给定内核模块参数的变化.

c linux kernel-module linux-kernel

5
推荐指数
2
解决办法
7987
查看次数

sscanf()是否支持“递归”缓冲区?

我进行了一些研究,以查找sscanf()源代码。但是我找不到我问题的答案。

当我们sscanf()以这种方式使用时:

char str[50] = "5,10,15";
int x;
sscanf(str,"%d,%s",&x,str);
Run Code Online (Sandbox Code Playgroud)

sscanf()是否支持“递归”缓冲区str

c scanf

5
推荐指数
1
解决办法
515
查看次数

What is the use of fork() - ing before exec()?

In *nix systems, processes are created by using fork() system call. Consider for example, init process creates another process.. First it forks itself and creates the a process which has the context like init. Only on calling exec(), this child process turns out to be a new process. So why is the intermediate step ( of creating a child with same context as parent ) needed? Isn't that a waste of time and resource, because we are creating a context …

c unix process

5
推荐指数
1
解决办法
2235
查看次数

这是一种使堆栈缓冲区为八字节对齐的可移植方式吗?

struct {
  uint64_t a; char z[120];
} b;

...

struct buffer_with_alignment_requirement* c = (struct buffer_w*)&b;
c->start_using_it;
Run Code Online (Sandbox Code Playgroud)

如果没有第一个成员a,我们可能会在访问缓冲区中的字段时崩溃.简单地添加这样的成员以强制整个结构的对齐是否足够严格,是否可移植且正确?

这不是关于指针别名的问题,只是关于b堆栈上的地址是否总是八字节对齐.

c

5
推荐指数
1
解决办法
315
查看次数

如何在bash中将十进制转换为十六进制?

我在bash shell中有一个十进制数:

linux$ A=67
Run Code Online (Sandbox Code Playgroud)

如何在bash中将67打印为十六进制?

linux bash shell

5
推荐指数
1
解决办法
3万
查看次数

在sigaction处理程序中使用flock()

flock()通常是异步信号安全的,因为它是一个系统调用.它的语义使得以不同方式实现它变得困难.它不在POSIX的异步信号安全功能列表中,因为它根本不在POSIX中.

是否可以flock()在sigaction处理程序中使用没有问题?

c linux signals flock

5
推荐指数
1
解决办法
234
查看次数

如何使用“fcntl()”锁定和解锁pid文件

我在网上甚至在 stackoverflow 上进行了研究,以便找到一个fcntl()用于锁定和解锁 pid 文件的示例,"/var/run/myapp.pid"但我没有找到明确的示例。

您能否指出一个fcntl()用于锁定和解锁 pid 文件的示例?

不应阻止锁定(如果文件已被锁定)

c linux fcntl

5
推荐指数
1
解决办法
2724
查看次数

如果子项在后台启动并且父项已经退出,如何知道父进程

我有一个在前台运行的子进程,他的父亲已经退出.

proc/$pid/stat如果父项已经退出,则该文件不再包含父pid,并且它显示1而不是原始父pid

linux$cat /proc/6267/stat
6267 (test3.sh) S 1 6265 ......
#                 ^
#                 |
#        I expected to get the origin parent pid but I get 1
Run Code Online (Sandbox Code Playgroud)

为了快速重现此行为,我们可以使用以下脚本

test2.sh

#!/bin/sh
echo "test2=$$"
./test3.sh &
Run Code Online (Sandbox Code Playgroud)

test3.sh

#!/bin/sh
echo "test3=$$"
sleep 1000
Run Code Online (Sandbox Code Playgroud)

执行:

linux$ ./test2.sh
test2=6318
test3=6319
linux$ ps aux | grep test
 6319 root      1484 S    {test3.sh} /bin/sh ./test3.sh
linux$ cat /proc/6319/stat
6319 (test3.sh) S 1 6318 2138 34816 6.......
Run Code Online (Sandbox Code Playgroud)

linux bash shell process ash

5
推荐指数
1
解决办法
637
查看次数

标签 统计

c ×8

linux ×7

bash ×4

shell ×4

process ×2

ash ×1

fcntl ×1

flock ×1

kernel-module ×1

linux-kernel ×1

scanf ×1

signals ×1

syslog ×1

unix ×1