示例#1
0
EXPORT_C void* create_process(void (*aFn)(), char* aName, char* mode, int fids[3])
	{
#ifdef _UNICODE
	TPtrC8 ptr((TText8*)aName);
	TBuf<80> name;
	name.Copy(ptr);
#else
	TPtrC8 name((TText8*)aName);
#endif /* _UNICODE */
	struct cthread* t = new cthread;
	TFileName this_exe = t->iProcess.FileName();
	TBuf<256> cmd;
	cmd.Format(_L("%S %S"),&this_exe,&name);
	cmd.ZeroTerminate();

#ifdef _UNICODE
	wchar_t wmode[MAXPATHLEN+1];
	mbstowcs(wmode, mode, MAXPATHLEN);
	t->pid=wpopen3((const wchar_t*)cmd.Ptr(), wmode, 0, fids);
#else
	t->pid=popen3((const char*)cmd.Ptr(), mode, 0, fids);
#endif
	if (t->pid < 0)
		return 0;
	User::After(1000000); // 1 Second
	return (void*)t;
	}
示例#2
0
文件: merge.c 项目: mikeando/agb
char test_core_merge__compare_with_parents_merge_base(const char * commit_id, const char * filename) {
	char * cmd;
	int readfd;
	asprintf(&cmd,"(cd " REPODIR " ; git diff --name-status $(git merge-base $(git show --pretty=format:%%p %s))..%s | ( grep '\\<%s\\>' || true ) )", commit_id, commit_id, filename);
	if(g_debug) printf("repo_contains: running %s\n", cmd);
	pid_t pid = popen3(cmd, NULL, &readfd, NULL);


	char result=0;
	ssize_t bytes_read = read(readfd,&result,1);

	int status=0;
	waitpid(pid,&status,0);
	free(cmd);

	if(!WIFEXITED(status) || WEXITSTATUS(status)!=0 ) {
		cl_fail("git diff failed");
	}

	if( bytes_read==0 )
		return 0;
	return result;
}
示例#3
0
/* ARGSUSED */
void
startslave(const char *host, const char *utmp_host,
	   int autologin, char *autoname)
{
#ifndef __SYMBIAN32__
	int i;
#else	
    int fds[3];
    int pid;
#endif	

#ifdef AUTHENTICATION
    if (!autoname || !autoname[0])
	autologin = 0;

    if (autologin < auth_level) {
	fatal(net, "Authorization failed");
	exit(1);
    }
#endif

    {
	char *tbuf =
	    "\r\n*** Connection not encrypted! "
	    "Communication may be eavesdropped. ***\r\n";
#ifdef ENCRYPTION
	if (!no_warn && (encrypt_output == 0 || decrypt_input == 0))
#endif
	    writenet((unsigned char*)tbuf, strlen(tbuf));
    }
# ifdef	PARENT_DOES_UTMP
    utmp_sig_init();
# endif	/* PARENT_DOES_UTMP */

#ifdef __SYMBIAN32__
	pid=popen3("Z:\\sys\\bin\\zsh.exe", NULL, NULL, fds);
		
	if (pid==-1) 
		{
		fatalperror(net, "popen3");			
		}
#endif //__SYMBIAN32__

#ifndef __SYMBIAN32__		
    if ((i = fork()) < 0)
	fatalperror(net, "fork");
    if (i) {
# ifdef PARENT_DOES_UTMP
	/*
	 * Cray parent will create utmp entry for child and send
	 * signal to child to tell when done.  Child waits for signal
	 * before doing anything important.
	 */
	int pid = i;
	void sigjob (int);

	setpgrp();
	utmp_sig_reset();		/* reset handler to default */
	/*
	 * Create utmp entry for child
	 */
	wtmp.ut_time = time(NULL);
	wtmp.ut_type = LOGIN_PROCESS;
	wtmp.ut_pid = pid;
	strncpy(wtmp.ut_user,  "LOGIN", sizeof(wtmp.ut_user));
	strncpy(wtmp.ut_host,  utmp_host, sizeof(wtmp.ut_host));
	strncpy(wtmp.ut_line,  clean_ttyname(line), sizeof(wtmp.ut_line));
#ifdef HAVE_STRUCT_UTMP_UT_ID
	strncpy(wtmp.ut_id, wtmp.ut_line + 3, sizeof(wtmp.ut_id));
#endif

	pututline(&wtmp);
	endutent();
	if ((i = open(wtmpf, O_WRONLY|O_APPEND)) >= 0) {
	    write(i, &wtmp, sizeof(struct utmp));
	    close(i);
	}
#ifdef	_CRAY
	signal(WJSIGNAL, sigjob);
#endif
	utmp_sig_notify(pid);
# endif	/* PARENT_DOES_UTMP */
    } else {
	getptyslave();
#if defined(DCE)
	/* if we authenticated via K5, try and join the PAG */
	kerberos5_dfspag();
#endif
	start_login(host, autologin, autoname);
	/*NOTREACHED*/
    } 
#endif//__SYMBIAN32__     
}