зеркало из https://github.com/github/ruby.git
* configure.in (pid_t, uid_t, gid_t): check if defined.
* intern.h, process.c, rubyio.h, ext/etc/etc.c, ext/pty/pty.c: use rb_{pid,uid,gid}_t instead of plain int. [ruby-dev:30376] * ext/etc/extconf.rb (PIDT2NUM, NUM2PIDT, UIDT2NUM, NUM2UIDT, GIDT2NUM, NUM2GIDT): moved to configure.in. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@11770 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
Родитель
bf6efa76c0
Коммит
562f256c54
|
@ -76,8 +76,8 @@ setup_passwd(struct passwd *pwd)
|
|||
#ifdef HAVE_ST_PW_PASSWD
|
||||
safe_setup_str(pwd->pw_passwd),
|
||||
#endif
|
||||
PW_UID2VAL(pwd->pw_uid),
|
||||
PW_GID2VAL(pwd->pw_gid),
|
||||
UIDT2NUM(pwd->pw_uid),
|
||||
GIDT2NUM(pwd->pw_gid),
|
||||
#ifdef HAVE_ST_PW_GECOS
|
||||
safe_setup_str(pwd->pw_gecos),
|
||||
#endif
|
||||
|
@ -125,7 +125,7 @@ etc_getpwuid(int argc, VALUE *argv, VALUE obj)
|
|||
|
||||
rb_secure(4);
|
||||
if (rb_scan_args(argc, argv, "01", &id) == 1) {
|
||||
uid = PW_VAL2UID(id);
|
||||
uid = NUM2UIDT(id);
|
||||
}
|
||||
else {
|
||||
uid = getuid();
|
||||
|
@ -301,7 +301,7 @@ setup_group(struct group *grp)
|
|||
#ifdef HAVE_ST_GR_PASSWD
|
||||
safe_setup_str(grp->gr_passwd),
|
||||
#endif
|
||||
PW_GID2VAL(grp->gr_gid),
|
||||
GIDT2NUM(grp->gr_gid),
|
||||
mem);
|
||||
}
|
||||
#endif
|
||||
|
|
|
@ -24,20 +24,5 @@ if a or b or c
|
|||
have_struct_member('struct passwd', 'pw_expire', 'pwd.h')
|
||||
have_struct_member('struct passwd', 'pw_passwd', 'pwd.h')
|
||||
have_struct_member('struct group', 'gr_passwd', 'grp.h')
|
||||
[%w"uid_t pwd.h", %w"gid_t grp.h"].each do |t, *h|
|
||||
h.unshift("sys/types.h")
|
||||
f = "INT2NUM"
|
||||
if have_type(t, h)
|
||||
if try_static_assert("sizeof(#{t}) > sizeof(long)", h)
|
||||
f = "LL2NUM"
|
||||
end
|
||||
if try_static_assert("(#{t})-1 > 0", h)
|
||||
f = "U#{f}"
|
||||
end
|
||||
end
|
||||
t = t.chomp('_t').upcase
|
||||
$defs.push("-DPW_#{t}2VAL=#{f}")
|
||||
$defs.push("-DPW_VAL2#{t}=#{f.sub(/([A-Z]+)2(NUM)/, '\22\1')}")
|
||||
end
|
||||
create_makefile("etc")
|
||||
end
|
||||
|
|
|
@ -147,7 +147,8 @@ raise_from_wait(char *state, struct pty_info *info)
|
|||
static VALUE
|
||||
pty_syswait(struct pty_info *info)
|
||||
{
|
||||
int cpid, status;
|
||||
rb_pid_t cpid;
|
||||
int status;
|
||||
|
||||
for (;;) {
|
||||
cpid = rb_waitpid(info->child_pid, &status, WUNTRACED);
|
||||
|
@ -192,6 +193,7 @@ static void
|
|||
establishShell(int argc, VALUE *argv, struct pty_info *info)
|
||||
{
|
||||
int i,master,slave;
|
||||
rb_pid_t pid;
|
||||
char *p,*getenv();
|
||||
struct passwd *pwent;
|
||||
VALUE v;
|
||||
|
@ -218,13 +220,13 @@ establishShell(int argc, VALUE *argv, struct pty_info *info)
|
|||
getDevice(&master,&slave);
|
||||
|
||||
info->thread = rb_thread_current();
|
||||
if((i = fork()) < 0) {
|
||||
if ((pid = fork()) < 0) {
|
||||
close(master);
|
||||
close(slave);
|
||||
rb_sys_fail("fork failed");
|
||||
}
|
||||
|
||||
if(i == 0) { /* child */
|
||||
if (pid == 0) { /* child */
|
||||
/*
|
||||
* Set free from process group and controlling terminal
|
||||
*/
|
||||
|
@ -282,7 +284,7 @@ establishShell(int argc, VALUE *argv, struct pty_info *info)
|
|||
|
||||
close(slave);
|
||||
|
||||
info->child_pid = i;
|
||||
info->child_pid = pid;
|
||||
info->fd = master;
|
||||
}
|
||||
|
||||
|
@ -420,7 +422,7 @@ pty_getpty(int argc, VALUE *argv, VALUE self)
|
|||
res = rb_ary_new2(3);
|
||||
rb_ary_store(res,0,(VALUE)rport);
|
||||
rb_ary_store(res,1,(VALUE)wport);
|
||||
rb_ary_store(res,2,INT2FIX(info.child_pid));
|
||||
rb_ary_store(res,2,PIDT2NUM(info.child_pid));
|
||||
|
||||
thinfo.thread = rb_thread_create(pty_syswait, (void*)&info);
|
||||
thinfo.child_pid = info.child_pid;
|
||||
|
|
|
@ -840,7 +840,7 @@ rb_w32_pipe_exec(const char *cmd, const char *prog, int mode, int *pipe)
|
|||
return ret;
|
||||
}
|
||||
|
||||
int
|
||||
rb_pid_t
|
||||
rb_w32_spawn(int mode, const char *cmd, const char *prog)
|
||||
{
|
||||
struct ChildRecord *child;
|
||||
|
@ -877,7 +877,7 @@ rb_w32_spawn(int mode, const char *cmd, const char *prog)
|
|||
}
|
||||
}
|
||||
|
||||
int
|
||||
rb_pid_t
|
||||
rb_w32_aspawn(int mode, const char *prog, char *const *argv)
|
||||
{
|
||||
int len = rb_w32_argv_size(argv);
|
||||
|
@ -2952,7 +2952,7 @@ poll_child_status(struct ChildRecord *child, int *stat_loc)
|
|||
}
|
||||
|
||||
rb_pid_t
|
||||
waitpid (rb_pid_t pid, int *stat_loc, int options)
|
||||
waitpid(rb_pid_t pid, int *stat_loc, int options)
|
||||
{
|
||||
DWORD timeout;
|
||||
|
||||
|
|
|
@ -229,8 +229,8 @@ extern int gettimeofday(struct timeval *, struct timezone *);
|
|||
extern rb_pid_t waitpid (rb_pid_t, int *, int);
|
||||
extern int rb_w32_argv_size(char *const *);
|
||||
extern char *rb_w32_join_argv(char *, char *const *);
|
||||
extern int rb_w32_spawn(int, const char *, const char*);
|
||||
extern int rb_w32_aspawn(int, const char *, char *const *);
|
||||
extern rb_pid_t rb_w32_spawn(int, const char *, const char*);
|
||||
extern rb_pid_t rb_w32_aspawn(int, const char *, char *const *);
|
||||
extern int kill(int, int);
|
||||
extern int fcntl(int, int, ...);
|
||||
extern rb_pid_t rb_w32_getpid(void);
|
||||
|
|
Загрузка…
Ссылка в новой задаче