#include  <unistd.h>
#include  <dlfcn.h> // 需要定义 _GNU_SOURCE,链接:-ldl

// 获取可执行程序或.so的路径
string GeCurrentModuleDir()
{
	string sPath = "./";

	Dl_info dlinfo;
	int ret = dladdr((void*)GeCurrentModuleDir, &dlinfo);
	if (ret != 0)
	{
		sPath = dlinfo.dli_fname;
	}

	std::size_t pos = sPath.find_last_of('/');
	if (pos != string::npos)
	{
		sPath = sPath.substr(0,pos);
	}

	return sPath;
}

// 获取可执行程序的路径
string GeCurrentExeDir()
{
	char szExePath[500];
	strcpy(szExePath,"./");

	int cnt = readlink("/proc/self/exe", szExePath, 500);

	string sPath = szExePath;
	std::size_t pos = sPath.find_last_of('/');
	if (pos != string::npos)
	{
		sPath = sPath.substr(0, pos);
	}

	return sPath;
}



本文链接地址: Linux下获取可执行程序或.so的路径
https://blog.qingfengju.com/index.asp?id=400

分类:Linux 查看次数:11763 发布时间:2016/12/29 12:03:20

修改Redis集群中各节点的redis.conf并重启: 

masterauth 1234!5 

requirepass 1234!5 


参考:http://blog.csdn.net/jtbrian/article/details/53691540



本文链接地址: 修改Redis集群的密码
https://blog.qingfengju.com/index.asp?id=409

分类:杂谈随感 查看次数:5460 发布时间:2016/12/20 10:00:15