当前位置: 首页>>代码示例>>C++>>正文


C++ wperror函数代码示例

本文整理汇总了C++中wperror函数的典型用法代码示例。如果您正苦于以下问题:C++ wperror函数的具体用法?C++ wperror怎么用?C++ wperror使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了wperror函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: exec_write_and_exit

// Called in a forked child
static void exec_write_and_exit(int fd, const char *buff, size_t count, int status)
{
    if (write_loop(fd, buff, count) == -1)
    {
        debug(0, WRITE_ERROR);
        wperror(L"write");
        exit_without_destructors(status);
    }
    exit_without_destructors(status);
}
开发者ID:DarkStarSword,项目名称:fish-shell,代码行数:11,代码来源:exec.cpp

示例2: terminal_return_from_job

/// Returns control of the terminal to the shell, and saves the terminal attribute state to the job,
/// so that we can restore the terminal ownership to the job at a later time.
static bool terminal_return_from_job(job_t *j) {
    errno = 0;
    if (j->pgid == 0) {
        debug(2, "terminal_return_from_job() returning early due to no process group");
        return true;
    }

    signal_block();
    if (tcsetpgrp(STDIN_FILENO, getpgrp()) == -1) {
        if (errno == ENOTTY) redirect_tty_output();
        debug(1, _(L"Could not return shell to foreground"));
        wperror(L"tcsetpgrp");
        signal_unblock();
        return false;
    }

    // Save jobs terminal modes.
    if (tcgetattr(STDIN_FILENO, &j->tmodes)) {
        if (errno == EIO) redirect_tty_output();
        debug(1, _(L"Could not return shell to foreground"));
        wperror(L"tcgetattr");
        signal_unblock();
        return false;
    }

// Disabling this per
// https://github.com/adityagodbole/fish-shell/commit/9d229cd18c3e5c25a8bd37e9ddd3b67ddc2d1b72 On
// Linux, 'cd . ; ftp' prevents you from typing into the ftp prompt. See
// https://github.com/fish-shell/fish-shell/issues/121
#if 0
    // Restore the shell's terminal modes.
    if (tcsetattr(STDIN_FILENO, TCSADRAIN, &shell_modes) == -1) {
        if (errno == EIO) redirect_tty_output();
        debug(1, _(L"Could not return shell to foreground"));
        wperror(L"tcsetattr");
        return false;
    }
#endif

    signal_unblock();
    return true;
}
开发者ID:Sam0523,项目名称:fish-shell,代码行数:44,代码来源:proc.cpp

示例3: wperror

 ~universal_notifier_shmem_poller_t()
 {
     if (region != NULL)
     {
         // Behold: C++ in all its glory!
         void *address = const_cast<void *>(static_cast<volatile void *>(region));
         if (munmap(address, sizeof(universal_notifier_shmem_t)) < 0)
         {
             wperror(L"munmap");
         }
     }
 }
开发者ID:hadoocn,项目名称:fish-shell,代码行数:12,代码来源:env_universal_common.cpp

示例4: dump_memory

int dump_memory(DWORD PID,PBYTE pbStartingAddress,DWORD iLength,char * szFile)
{
	FILE * fp=fopen(szFile,"wb+");
	void * pbMemory;
	DWORD iRead;
	HANDLE hProcess;
	
	utils_debug("Dumping Process : %08x, from %08x, length %08x, to file %s.\n",PID,pbStartingAddress,iLength,szFile);
	if(!fp){
		utils_error("Open %s(read/write) failed.\n",fp);
		return 0;
	};
	pbMemory=malloc(iLength);
	if(!pbMemory){
		utils_error("Memory allocation failed (%d bytes).\n",iLength);
		fclose(fp);
		return 0;
	};

	if( !(hProcess=OpenProcess(PROCESS_ALL_ACCESS,0,PID)) ){
		wperror("OpenProcess failed:");
		free(pbMemory);
		fclose(fp);
		return 0;
	}
	if( !ReadProcessMemory(hProcess,pbStartingAddress,pbMemory,iLength,&iRead)){
		wperror("ReadProcessMemory failed:");
		free(pbMemory);
		fclose(fp);
		return 0;
	};

	fwrite(pbMemory,1,iLength,fp);

	utils_trace("Ok, %d bytes written.\n",iLength);

	free(pbMemory);
	fclose(fp);
	return 1;
};
开发者ID:eseawind,项目名称:CNCS_PMC-Conductor,代码行数:40,代码来源:procdump.c

示例5: terminal_return_from_job

/**
   Returns control of the terminal to the shell, and saves the terminal
   attribute state to the job, so that we can restore the terminal
   ownership to the job at a later time .
*/
static int terminal_return_from_job(job_t *j)
{

    if (tcsetpgrp(0, getpgrp()))
    {
        debug(1, _(L"Could not return shell to foreground"));
        wperror(L"tcsetpgrp");
        return 0;
    }

    /*
       Save jobs terminal modes.
    */
    if (tcgetattr(0, &j->tmodes))
    {
        debug(1, _(L"Could not return shell to foreground"));
        wperror(L"tcgetattr");
        return 0;
    }

    /* Disabling this per https://github.com/adityagodbole/fish-shell/commit/9d229cd18c3e5c25a8bd37e9ddd3b67ddc2d1b72
       On Linux, 'cd . ; ftp' prevents you from typing into the ftp prompt
       See https://github.com/fish-shell/fish-shell/issues/121
    */
#if 0
    /*
       Restore the shell's terminal modes.
    */
    if (tcsetattr(0, TCSADRAIN, &shell_modes))
    {
        debug(1, _(L"Could not return shell to foreground"));
        wperror(L"tcsetattr");
        return 0;
    }
#endif

    return 1;
}
开发者ID:GarethLewin,项目名称:fish-shell,代码行数:43,代码来源:proc.cpp

示例6: io_buffer_t

io_buffer_t *io_buffer_t::create(bool is_input, int fd)
{
    bool success = true;
    if (fd == -1)
    {
        fd = is_input ? 0 : 1;
    }
    io_buffer_t *buffer_redirect = new io_buffer_t(fd, is_input);

    if (exec_pipe(buffer_redirect->pipe_fd) == -1)
    {
        debug(1, PIPE_ERROR);
        wperror(L"pipe");
        success = false;
    }
    else if (fcntl(buffer_redirect->pipe_fd[0],
                   F_SETFL,
                   O_NONBLOCK))
    {
        debug(1, PIPE_ERROR);
        wperror(L"fcntl");
        success = false;
    }

    if (! success)
    {
        delete buffer_redirect;
        buffer_redirect = NULL;
    }
    else
    {
        //fprintf(stderr, "Created pipes {%d, %d} for %p\n", buffer_redirect->pipe_fd[0], buffer_redirect->pipe_fd[1], buffer_redirect);
    }

    return buffer_redirect;
}
开发者ID:ViciousPotato,项目名称:fish-shell,代码行数:36,代码来源:io.cpp

示例7: exec_close

void exec_close(int fd) {
    ASSERT_IS_MAIN_THREAD();

    // This may be called in a child of fork(), so don't allocate memory.
    if (fd < 0) {
        debug(0, L"Called close on invalid file descriptor ");
        return;
    }

    while (close(fd) == -1) {
        debug(1, FD_ERROR, fd);
        wperror(L"close");
        break;
    }
}
开发者ID:moverest,项目名称:fish-shell,代码行数:15,代码来源:exec.cpp

示例8: read_file

// Read the entire contents of a file into the specified string.
static wcstring read_file(FILE *f) {
    wcstring result;
    while (1) {
        wint_t c = fgetwc(f);
        if (c == WEOF) {
            if (ferror(f)) {
                wperror(L"fgetwc");
                exit(1);
            }
            break;
        }
        result.push_back((wchar_t)c);
    }
    return result;
}
开发者ID:Sam0523,项目名称:fish-shell,代码行数:16,代码来源:fish_indent.cpp

示例9: assert

shared_ptr<io_buffer_t> io_buffer_t::create(int fd, const io_chain_t &conflicts,
                                            size_t buffer_limit) {
    bool success = true;
    assert(fd >= 0);
    shared_ptr<io_buffer_t> buffer_redirect(new io_buffer_t(fd, buffer_limit));

    if (exec_pipe(buffer_redirect->pipe_fd) == -1) {
        debug(1, PIPE_ERROR);
        wperror(L"pipe");
        success = false;
    } else if (!buffer_redirect->avoid_conflicts_with_io_chain(conflicts)) {
        // The above call closes the fds on error.
        success = false;
    } else if (make_fd_nonblocking(buffer_redirect->pipe_fd[0]) != 0) {
        debug(1, PIPE_ERROR);
        wperror(L"fcntl");
        success = false;
    }

    if (!success) {
        buffer_redirect.reset();
    }
    return buffer_redirect;
}
开发者ID:elnappo,项目名称:fish-shell,代码行数:24,代码来源:io.cpp

示例10: assert

io_buffer_t *io_buffer_t::create(int fd, const io_chain_t &conflicts) {
    bool success = true;
    assert(fd >= 0);
    io_buffer_t *buffer_redirect = new io_buffer_t(fd);

    if (exec_pipe(buffer_redirect->pipe_fd) == -1) {
        debug(1, PIPE_ERROR);
        wperror(L"pipe");
        success = false;
    } else if (!buffer_redirect->avoid_conflicts_with_io_chain(conflicts)) {
        // The above call closes the fds on error.
        success = false;
    } else if (make_fd_nonblocking(buffer_redirect->pipe_fd[0]) != 0) {
        debug(1, PIPE_ERROR);
        wperror(L"fcntl");
        success = false;
    }

    if (!success) {
        delete buffer_redirect;
        buffer_redirect = NULL;
    }
    return buffer_redirect;
}
开发者ID:haarts,项目名称:fish-shell,代码行数:24,代码来源:io.cpp

示例11: read_try

/**
   Read from descriptors until they are empty.

   \param j the job to test
*/
static void read_try(job_t *j)
{
    io_buffer_t *buff = NULL;

    /*
      Find the last buffer, which is the one we want to read from
    */
    const io_chain_t chain = j->all_io_redirections();
    for (size_t idx = 0; idx < chain.size(); idx++)
    {
        io_data_t *d = chain.at(idx).get();
        if (d->io_mode == IO_BUFFER)
        {
            buff = static_cast<io_buffer_t *>(d);
        }
    }

    if (buff)
    {
        debug(3, L"proc::read_try('%ls')\n", j->command_wcstr());
        while (1)
        {
            char b[BUFFER_SIZE];
            long l;

            l=read_blocked(buff->pipe_fd[0],
                           b, BUFFER_SIZE);
            if (l==0)
            {
                break;
            }
            else if (l<0)
            {
                if (errno != EAGAIN)
                {
                    debug(1,
                          _(L"An error occured while reading output from code block"));
                    wperror(L"read_try");
                }
                break;
            }
            else
            {
                buff->out_buffer_append(b, l);
            }
        }
    }
}
开发者ID:GarethLewin,项目名称:fish-shell,代码行数:53,代码来源:proc.cpp

示例12: load_or_save

/**
   Load or save all variables
*/
static void load_or_save( int save)
{
	const wcstring wdir = fishd_get_config();
	char hostname[HOSTNAME_LEN];
	connection_t c;
	int fd;
	
	if (wdir.empty())
		return;
	
	std::string dir = wcs2string( wdir );
	
	gethostname( hostname, HOSTNAME_LEN );
	
    std::string name;
    name.append(dir);
    name.append("/");
    name.append(FILE);
    name.append(hostname);
	
	debug( 4, L"Open file for %s: '%s'", 
		   save?"saving":"loading", 
		   name.c_str() );
	
    /* OK to not use CLO_EXEC here because fishd is single threaded */
	fd = open(name.c_str(), save?(O_CREAT | O_TRUNC | O_WRONLY):O_RDONLY, 0600);
	
	if( fd == -1 )
	{
		debug( 1, L"Could not open load/save file. No previous saves?" );
		wperror( L"open" );
		return;		
	}
	debug( 4, L"File open on fd %d", c.fd );

	connection_init( &c, fd );

	if( save )
	{
		
		write_loop( c.fd, SAVE_MSG, strlen(SAVE_MSG) );
		enqueue_all( &c );
	}
	else
		read_message( &c );

	connection_destroy( &c );	
}
开发者ID:Soares,项目名称:fish-shell,代码行数:51,代码来源:fishd.cpp

示例13: connection_destroy

void connection_destroy(connection_t *c)
{
    if (c->unsent) delete c->unsent;

    /*
      A connection need not always be open - we only try to close it
      if it is open.
    */
    if (c->fd >= 0)
    {
        if (close(c->fd))
        {
            wperror(L"close");
        }
    }
}
开发者ID:ciembor,项目名称:fish-shell,代码行数:16,代码来源:env_universal_common.cpp

示例14: check_size

/**
   Tests if the tokenizer buffer is large enough to hold contents of
   the specified length, and if not, reallocates the tokenizer buffer.

   \return 0 if the system could not provide the memory needed, and 1 otherwise.
*/
static int check_size( tokenizer *tok, size_t len )
{
	if( tok->last_len <= len )
	{
		wchar_t *tmp;
		tok->last_len = len +1;
		tmp = realloc( tok->last, sizeof(wchar_t)*tok->last_len );
		if( tmp == 0 )
		{
			wperror( L"realloc" );
			return 0;
		}
		tok->last = tmp;
	}
	return 1;
}
开发者ID:brentdax,项目名称:fishfish,代码行数:22,代码来源:tokenizer.c

示例15: exec_close

void io_buffer_t::read()
{
    exec_close(pipe_fd[1]);

    if (io_mode == IO_BUFFER)
    {
        /*    if( fcntl( pipe_fd[0], F_SETFL, 0 ) )
            {
              wperror( L"fcntl" );
              return;
              }  */
        debug(4, L"io_buffer_t::read: blocking read on fd %d", pipe_fd[0]);
        while (1)
        {
            char b[4096];
            long l;
            l=read_blocked(pipe_fd[0], b, 4096);
            if (l==0)
            {
                break;
            }
            else if (l<0)
            {
                /*
                  exec_read_io_buffer is only called on jobs that have
                  exited, and will therefore never block. But a broken
                  pipe seems to cause some flags to reset, causing the
                  EOF flag to not be set. Therefore, EAGAIN is ignored
                  and we exit anyway.
                */
                if (errno != EAGAIN)
                {
                    debug(1,
                          _(L"An error occured while reading output from code block on file descriptor %d"),
                          pipe_fd[0]);
                    wperror(L"io_buffer_t::read");
                }

                break;
            }
            else
            {
                out_buffer_append(b, l);
            }
        }
    }
}
开发者ID:Aulos,项目名称:fish-shell,代码行数:47,代码来源:io.cpp


注:本文中的wperror函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。