(ctx context.Context, data wshrpc.CommandBadgeWatchPidData)
| 139 | } |
| 140 | |
| 141 | func (impl *ServerImpl) BadgeWatchPidCommand(ctx context.Context, data wshrpc.CommandBadgeWatchPidData) error { |
| 142 | if data.Pid <= 0 { |
| 143 | return fmt.Errorf("invalid pid: %d", data.Pid) |
| 144 | } |
| 145 | if data.ORef.IsEmpty() { |
| 146 | return fmt.Errorf("oref is required") |
| 147 | } |
| 148 | if data.BadgeId == "" { |
| 149 | return fmt.Errorf("badgeid is required") |
| 150 | } |
| 151 | go func() { |
| 152 | defer func() { |
| 153 | panichandler.PanicHandler("BadgeWatchPidCommand", recover()) |
| 154 | }() |
| 155 | for { |
| 156 | time.Sleep(time.Second) |
| 157 | if unixutil.IsPidRunning(data.Pid) { |
| 158 | continue |
| 159 | } |
| 160 | orefStr := data.ORef.String() |
| 161 | event := wps.WaveEvent{ |
| 162 | Event: wps.Event_Badge, |
| 163 | Scopes: []string{orefStr}, |
| 164 | Data: baseds.BadgeEvent{ |
| 165 | ORef: orefStr, |
| 166 | ClearById: data.BadgeId, |
| 167 | }, |
| 168 | } |
| 169 | wshclient.EventPublishCommand(impl.RpcClient, event, nil) |
| 170 | log.Printf("BadgeWatchPidCommand: pid %d gone, cleared badge %s for oref %s\n", data.Pid, data.BadgeId, orefStr) |
| 171 | return |
| 172 | } |
| 173 | }() |
| 174 | return nil |
| 175 | } |
nothing calls this directly
no test coverage detected