cation copy.
	std::fstream lock("json2db.pid");
	if (!lock.is_open())
	{
		stderr << "" << endl;
		printf("%s\n", "ERROR: can't open lock file.");
		return -1;
	}
	lock >> pid;
	lock.close();

	// Process --kill input parameter.
	if (std::string(argv[1]) == "--kill")
	{
		// Kill process if exists.
		if (pid)
			kill(pid, SIGKILL);
		// Open file.
		lock.open("json2db.pid", std::fstream::in | std::fstream::out | std::fstream::trunc);
		lock.close();
		stdout << "INFO: process killed." << endl;
		return 0;
	}
	else if (std::string(argv[1]) == "--stop")
	{
		// Terminate process if exists.
		if (pid)
			kill(pid, SIGTERM);
	}
	else if (std::string(argv[1]) == "--start")
	{
		// Terminate process if exists.
		if (pid)
			kill(pid, SIGTERM);
	}
	else if (std::string(argv[1]) == "--help")
	{
		return 0;
	}
	else
	{
		stderr << "ERROR: invalid command line option." << endl << "Use --help for details." << endl;
		return -1;
	}

	if (signal(SIGTERM, sig_handler) == SIG_ERR)
	{
		stderr << "ERROR: unable to set SEGTERM handler." << endl;
		return -1;
	}


	lock.open("json2db.pid", std::fstream::in | std::fstream::out | std::fstream::trunc);
	lock << getpid();
	lock.close();

	// Load settings.
	if (!Options::LoadFromFile("config.json"))
	{
		printf("%s\n", "ERROR: invalid configuration file.");
		lock.open("json2db.pid", std::fstream::in | std::fstream::out | std::fstream::trunc);
		lock.close();
		return -1;
	}

	// Initialize CURL.
	curl_global_init(CURL_GLOBAL_ALL);

	// Start main loop.
	pthread_attr_init(&attr);
	pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_DETACHED);
	pthread_create(&pthread, &attr, ::MainThread, (void *) urlIt->c_str());
	pthread_join(pthread, NULL); 

	// Manage keyboard input.
	std::string keyValue;
	while (keyValue != "quit")
	{
		if (!keyValue.size())
			stderr << "ERROR: unknown command '" << keyValue << "'" << endl;
		cin >> keyValue;
	}

	// Cleanup lock file.
	lock.open("json2db.pid", std::fstream::in | std::fstream::out | std::fstream::trunc);
	lock.close();

	// Wait for finishing of the main loop thread.
	Options::_toTetminate = true;
	while (Options::_toTetminate)
		usleep(1000u);

	// Cleanup CURL.
	curl_global_cleanup();

	return 0;
}
