
#include<signal.h>
#include<stdio.h>
#include<sys/types.h>
#include<unistd.h>
int ntimes=0
void p_action(int)
void c_action(int)
main()
{
int pid,ppid
signal(SIGUSR1,p_action)
switch(pid=fork()){
case -1:
perror("synchro")
break
case 0:
signal (SIGUSR1,c_action)
ppid=getppid()
printf("%d\n",ppid)
for()
{
sleep(1)
kill(ppid,SIGUSR1)
pause()
}
break
default:
printf("father\n")
for()
{
pause()
sleep(1)
kill(pid,SIGUSR1)
}
}
}
void p_action (int sig)
{
printf("p\n")
// printf("Patent caught signal #%d\n",++ntimes)
}
void c_action (int sig)
{
printf("c\n")
//printf("child caught signal #%d\n",++ntimes)
}
这个是你没有设定,内核的root在启动linux时,出现上面这个错误,许多情况下是因为,没有在grub.conf(或者你没有安装grub,而用的是grub4dos的menu.lst文件)文件,没有指定根文件系统.Do not forget that you have to specify a root partion to the kernel.(Grub 手册)这里给出一个例子,一看你就明白了。timeout=10defalut=0title Redhat Enterprise Linux 5kernel (hd0,7)/boot/vmlinuz-2.6.18-194.el5 ro root=/dev/sda8 rhgb quietinitrd (hd0,7)/boot/initrd-2.6.18-194.el5.imgro 参数告诉内核以只读方式加载根文件系统,以便进行文件系统完整性检查rhgb 指的是redhat graphics boot,图形界面启动显示;quiet指的是,仅列出简要的信息。其实,只要加上上面黑体的那句就可以启动了。方法一:编辑rc.loacl脚本
直接在/etc/rc.local中添加启动脚本。
方法二:Linux通过chkconfig设置开机启动服务
创建脚本
编辑脚本内容如下(脚本前面三行格式固定)
说明:
第一行,告诉系统使用的shell,所有的shell脚本都是这样。
第二行,chkconfig后面有三个参数2345,100和101告诉chkconfig程序,需要在rc2.d~rc5.d目录下,创建名字为 S100bootshell的文件连接,连接到/etc/rc.d/init.d目录下的的test2脚本。第一个字符是S,系统在启动的时候,运行脚本bootshell,就会添加一个start参数,告诉脚本,现在是启动模式。同时在rc0.d和rc6.d目录下,创建名字为K90bootshell的 文件连接,第一个字符为K,系统在关闭系统的时候,会运行bootshell,添加一个stop,告诉脚本,现在是关闭模式。 注意上面的三行中,第二,第三行是必须的,否则在运行chkconfig --add bootshell时,会报错。
运行级别,越小越优先运行,优先级相同的时候按创建时间启动。
给文件设置执行权限
测试脚本
chkconfig创建服务
此时rc2.d-rc5.d文件夹下已有创建好的文件。
在CentOS中服务启动脚本放置在: /etc/rc.d/init.d 而 /etc/init.d 这个目录为公认的目录,在centos中 /etc/init.d 就是一个链接档案 /etc/sysconfig 服务初始化环境变量配置都在这个档案中。
欢迎分享,转载请注明来源:内存溢出
微信扫一扫
支付宝扫一扫
评论列表(0条)