}
else if ( pid == 0 ) // we're in child
{
- // These lines close the open file descriptors to to avoid any
- // input/output which might block the process or irritate the user. If
- // one wants proper IO for the subprocess, the right thing to do is to
- // start an xterm executing it.
- if ( !(flags & wxEXEC_SYNC) )
- {
- // FD_SETSIZE is unsigned under BSD, signed under other platforms
- // so we need a cast to avoid warnings on all platforms
- for ( int fd = 0; fd < (int)FD_SETSIZE; fd++ )
- {
- if ( fd == pipeIn[wxPipe::Read]
- || fd == pipeOut[wxPipe::Write]
- || fd == pipeErr[wxPipe::Write]
- || fd == (execData.pipeEndProcDetect)[wxPipe::Write] )
- {
- // don't close this one, we still need it
- continue;
- }
-
- // leave stderr opened too, it won't do any harm
- if ( fd != STDERR_FILENO )
- close(fd);
- }
- }
+ // NB: we used to close all the unused descriptors of the child here
+ // but this broke some programs which relied on e.g. FD 1 being
+ // always opened so don't do it any more, after all there doesn't
+ // seem to be any real problem with keeping them opened
#if !defined(__VMS) && !defined(__EMX__)
if ( flags & wxEXEC_MAKE_GROUP_LEADER )
bool ok = uname(&uts) != -1;
if ( ok )
{
- wxStrncpy(buf, wxSafeConvertMB2WX(uts.nodename), sz - 1);
- buf[sz] = wxT('\0');
+ wxStrlcpy(buf, wxSafeConvertMB2WX(uts.nodename), sz);
}
#elif defined(HAVE_GETHOSTNAME)
char cbuf[sz];
bool ok = gethostname(cbuf, sz) != -1;
if ( ok )
{
- wxStrncpy(buf, wxSafeConvertMB2WX(cbuf), sz - 1);
- buf[sz] = wxT('\0');
+ wxStrlcpy(buf, wxSafeConvertMB2WX(cbuf), sz);
}
#else // no uname, no gethostname
wxFAIL_MSG(wxT("don't know host name for this machine"));
else
{
// the canonical name
- wxStrncpy(buf, wxSafeConvertMB2WX(host->h_name), sz);
+ wxStrlcpy(buf, wxSafeConvertMB2WX(host->h_name), sz);
}
}
//else: it's already a FQDN (BSD behaves this way)
*buf = wxT('\0');
if ((who = getpwuid(getuid ())) != NULL)
{
- wxStrncpy (buf, wxSafeConvertMB2WX(who->pw_name), sz - 1);
+ wxStrlcpy (buf, wxSafeConvertMB2WX(who->pw_name), sz);
return true;
}
char *comma = strchr(who->pw_gecos, ',');
if (comma)
*comma = '\0'; // cut off non-name comment fields
- wxStrncpy (buf, wxSafeConvertMB2WX(who->pw_gecos), sz - 1);
+ wxStrlcpy(buf, wxSafeConvertMB2WX(who->pw_gecos), sz);
return true;
}