void copy_file_as_user(const char *srcname, const char *destname, mode_t mode) {
	pid_t child = fork();
	if (child < 0)
		errExit("fork");
	if (child == 0) {
		// drop privileges
		drop_privs(0);

		// copy, set permissions
		int rv = copy_file(srcname, destname, -1, -1, mode); // already a regular user
		if (rv)
			fwarning("cannot copy %s\n", srcname);

		__gcov_flush();

		_exit(0);
	}
	// wait for the child to finish
	waitpid(child, NULL, 0);
}
void copy_file_as_user(const char *srcname, const char *destname, mode_t mode) {
	pid_t child = fork();
	if (child < 0)
		errExit("fork");
	if (child == 0) {
		 
		drop_privs(0);

		 
		int rv = copy_file(srcname, destname, -1, -1, mode);  
		if (rv)
			fwarning("cannot copy %s\n", srcname);

		__gcov_flush();

		_exit(0);
	}
	 
	waitpid(child, NULL, 0);
}