- 论坛徽章:
- 0
|
#include <sys/socket.h>
#include <netinet/in.h>
#include <unistd.h>
#define Ports 3306
main()
{
struct sockaddr_in server;
int socked,port;
server.sin_family=AF_INET;
server.sin_addr.s_addr=htonl(INADDR_ANY);
server.sin_port = htons((short)Ports);
socked=socket(AF_INET,SOCK_STREAM,0);
port=bind(socked,(struct sockaddr *)&server,sizeof(server));
if (port==0)
{
execlp("mysql.server","mysql.server","start",0);
}
}
执行这个程序检查 MYSQL 是否在运行,如果3306 关闭就执行 mysql.server start
但是每次执行后出现如下错误[root@localhost ~]
[root@localhost ~]# ./mysql.o
Starting MySQL../usr/bin/mysql.server: line 159: kill: (30662) - No such process [FAILED]
[root@localhost ~]#
请大家帮忙!!
[ 本帖最后由 修理工 于 2007-12-13 20:21 编辑 ] |
|