~ubuntu-branches/debian/stretch/screen/stretch

« back to all changes in this revision

Viewing changes to attacher.c

  • Committer: Package Import Robot
  • Author(s): Axel Beckert
  • Date: 2014-07-26 14:05:20 UTC
  • mfrom: (7.1.4 experimental)
  • Revision ID: package-import@ubuntu.com-20140726140520-68d50x42gevcjy5e
Tags: 4.2.1-2
* Upload to unstable again
* Enable parallel building

Show diffs side-by-side

added added

removed removed

Lines of Context:
133
133
  return 0;
134
134
}
135
135
 
136
 
int
137
 
WriteOldMessage(struct msg *m)
138
 
{
139
 
  sleep(1); /* give the server some time to reopen the pipe */
140
 
  if (m->type == MSG_ATTACH && (m->m.attach.detachfirst == MSG_ATTACH ||
141
 
                                m->m.attach.detachfirst == MSG_DETACH ||
142
 
                                m->m.attach.detachfirst == MSG_POW_DETACH))
143
 
    {
144
 
      struct old_msg old_m;
145
 
      int s;
146
 
      int r, l = sizeof(old_m);
147
 
 
148
 
      s = MakeClientSocket(0);
149
 
      if (s < 0)
150
 
        return 0;
151
 
      old_m.protocol_revision = (('m'<<24) | ('s'<<16) | ('g'<<8) | 0);
152
 
      old_m.type = m->type;
153
 
      memcpy(old_m.m_tty, m->m_tty, sizeof(old_m.m_tty));
154
 
      memcpy(old_m.m.attach.auser, m->m.attach.auser, sizeof(old_m.m.attach.auser));
155
 
      old_m.m.attach.apid = m->m.attach.apid;
156
 
      old_m.m.attach.adaptflag = m->m.attach.adaptflag;
157
 
      old_m.m.attach.lines = m->m.attach.lines;
158
 
      old_m.m.attach.columns = m->m.attach.columns;
159
 
      memcpy(old_m.m.attach.preselect, m->m.attach.preselect, sizeof(old_m.m.attach.preselect));
160
 
      old_m.m.attach.esc = m->m.attach.esc;
161
 
      old_m.m.attach.meta_esc = m->m.attach.meta_esc;
162
 
      memcpy(old_m.m.attach.envterm, m->m.attach.envterm, sizeof(old_m.m.attach.envterm));
163
 
      old_m.m.attach.encoding = m->m.attach.encoding;
164
 
      while(l > 0)
165
 
        {
166
 
          r = write(s, (char *)&old_m + (sizeof(struct old_msg) - l), l);
167
 
          if (r == -1 && errno == EINTR)
168
 
        continue;
169
 
          if (r == -1 || r == 0)
170
 
        return -1;
171
 
          l -= r;
172
 
        }
173
 
      close(s);
174
 
    }
175
 
  return 0;
176
 
}
177
 
 
178
136
 
179
137
int
180
138
Attach(how)
439
397
  if (WriteMessage(lasts, &m))
440
398
    Panic(errno, "WriteMessage");
441
399
  close(lasts);
442
 
  WriteOldMessage(&m);
443
400
  debug1("Attach(%d): sent\n", m.type);
444
401
#ifdef MULTIUSER
445
402
  if (multi && (how == MSG_ATTACH || how == MSG_CONT))